Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data empty in jQuery.get() callback

$.get("http://localhost/test.php", (function(data){
    alert(data);
}))

The alert is empty. I'm new to this, and I can't see what I'm doing wrong. Help?

like image 360
Dataflashsabot Avatar asked Feb 13 '26 23:02

Dataflashsabot


1 Answers

Perhaps you're not telling the code to run? Try putting it in $(document).ready() with

$(function() {
  $.get("http://localhost/test.php", function(data){
    alert(data);
  });
});

http://api.jquery.com/ready/

like image 178
Justin Force Avatar answered Feb 15 '26 12:02

Justin Force



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!