html - Submit Form after Calling getJSON in jQuery -
i have form:
$('#ambition_submit').click(function(e){ e.preventdefault(); var output = gettimelineentrydata(data.tojson());//console.log(output); $.getjson('http://www.x.com/x/api/add_subgoals.php',{action:'add.subgoals',ambition_id:ambition_id,subgoals:output}, function (response) { //var this_url = this.url; console.log(this_url); if (response.status == 200) { var result = response.message;//alert(response.message); $('#form_content').submit(); $('form[name=testing747]').submit();//console.log('test ' + $('form[name=testing747]').length); } else{ alert(response.message); } }); }); on submit want ajax run , on completion, form submit. how can form submit whatever outcome of ajax is?
thanks
so question:
how can form submit whatever outcome of ajax is?
for can utilize .always() works both success , error method chain ajax like:
$('#ambition_submit').click(function (e) { e.preventdefault(); var output = gettimelineentrydata(data.tojson()); //console.log(output); $.getjson('http://www.x.com/x/api/add_subgoals.php', { action: 'add.subgoals', ambition_id: ambition_id, subgoals: output }, function (response) { //var this_url = this.url; console.log(this_url); if (response.status == 200) { var result = response.message; //alert(response.message); } else { alert(response.message); } }).always(function () { $('#form_content').submit(); $('form[name=testing747]').submit(); //console.log('test ' + $('form[name=testing747]').length); }); }); jquery html ajax forms getjson
No comments:
Post a Comment