javascript - jQuery Ajax Options - I need advice -
when working on jquery ajax, think it's option "async", know meaning (asynchronous javascript , xml), need ajax before statement complete, example form validations, when check in db, if username exists, add in ajax option "async: false". bad way this? need youd advice :)
my code:
var content = $("#content"); function ajaxresponse() { var r = null; $.ajax({ type: 'post', url: 'data.html', async: false, success: function(data) { r = data; } }); return r; } setinterval(function(){ content.text(ajaxresponse()); },1000);
here how code except not post html page load html page instead
var content = $("#content"), tid; function ajaxresponse() { $.ajax({ type: 'post', url: 'data.php', success: function(data) { content.text(data); tid = settimeout(ajaxresponse,1000); // run again } }); } to update content html page:
content.load("somepage.html");
Comments
Post a Comment