GET request with jquery

All about creating websites!
Post Reply
User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

GET request with jquery

Post by l0ngb1t »

am learning jquery in order to migrate some apps to it.
i am facing a problem with get requests.
what am trying is very simple. an input field where the user input a text, the text fet send to a php page via get request and the page echo it back, the result is displayed in a div.

codes:

page code:

Code: Select all


<html>
	<input type="text" id="name"/><input type="button" id="btn" value="echo"/>
	<div id="disp"></div>
	
	<script type="text/javascript" src ="http://code.jquery.com/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src ="ajax.js"></script>

</html>


ajax.js code (it handles the get request

Code: Select all

$('#btn').click(function(){
	var name=$('#name').val();
	// alert (name);    <- this alert is executed but it stops here
	$.get("http://127.0.0.1/time.php", { msg : name }, function(data){
			$('#disp').text(data);
					});
	});
the php page

Code: Select all

<?php
  echo $_GET["msg"];
 ?>
any hints?
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: GET request with jquery

Post by ayu »

Working at the moment so can't put it up here to test it.
But if you can put the page live somewhere so that I can reach it, then I can run it quickly in my debugger and see what it does wrong.
"The best place to hide a tree, is in a forest"

User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

Re: GET request with jquery

Post by l0ngb1t »

can't do that now.
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: GET request with jquery

Post by ayu »

Alright, well then you will have to wait until tomorrow then, when I'm home again ^^
Or if someone else can help you :)
"The best place to hide a tree, is in a forest"

Post Reply