javascript - jQuery AJAX not entering "success" -
$(function(){ $(document).ready(function(){ $.ajax({ url: "src/cookiecheck.php", type: "post", async: true, success: function(json){ if(json.visitedbefore!="true"){ $("#cookiepolicy").fadein(); } } }); window.alert(5); $.ajax({ url: "src/lessons.php", type: "post", async: true, success: function(json){ window.alert(1); } }); }); });
so jquery part of application executes first ajax call , display 5 "window.alert(5);" second call made reason success not triggered. here how output "lessons.php" looks like
{"id":"5"} {"name":["111","2","3","4","5","123123"]} {"location":["1112","2","3","4","5","3123123"]}
this not valid json:
{"id":"5"} {"name":["111","2","3","4","5","123123"]} {"location":["1112","2","3","4","5","3123123"]}
perhaps format this:
{ "things": {"id":"5"}, "names": {"name":["111","2","3","4","5","123123"]}, "locations": {"location":["1112","2","3","4","5","3123123"]} }
Comments
Post a Comment