1 Replies - 4367 Views - Last Post: 30 October 2012 - 03:16 AM

#1 leixnt   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 24-July 11

jQuery don't work

Posted 26 October 2012 - 05:18 AM

hello friends, can anybody help me with this jquery
i've tried to display data from jquery post, but it show nothing...
here is my code

index.html
<script type="text/javascript" charset="utf-8">
			
$(document).ready(function(){
	$(document).mousemove(function(){
	sendValue("notif");	
	});	
});
			
function sendValue(str){
	$.post("ajax.php", { sendToValue: str },
	function(data){
	    $('#display').html(data.returnFromValue);
	}, "json");
}
</script>
<label for="txtValue">Enter a value : </label><input type="text" name="txtValue" value="" id="txtValue">
<div id="display"></div>



ajax.php
if (isset($_POST['sendToValue'])){
	$value = $_POST['sendToValue'];	
}else{
	$value = "";
}
echo json_encode(array("returnFromValue"=>"This is returned from PHP : ".$value));



from this coding should be appear:
This is returned from PHP : notif

but nothing appear.
im using google chrome

This post has been edited by leixnt: 26 October 2012 - 05:20 AM


Is This A Good Question/Topic? 0
  • +

Replies To: jQuery don't work

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6260
  • View blog
  • Posts: 24,030
  • Joined: 23-August 08

Re: jQuery don't work

Posted 30 October 2012 - 03:16 AM

Use Chrome's Developer Tools, set a breakpoint on the $('#display').html(data.returnFromValue); line. Does it get hit? If it doesn't, you're probably getting an error returned from the server. If it gets hit, is the value in data what you expect?

Basic Javascript debugging.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1