how to type ajax correctly? -


i know how use 1 form data use ajax:

$.ajax({        type:'get',        url:'blabla.php',        data:$('#abc').serialize();        ......... 

but how if want type:

$('#exportmod').click(function(){                     $.ajax({                             "datatype":'json',                             "type":'get',                             "url":'shows_merchan.php',                             "data": [ action:"searchmodelqp",                                       jhead:"aadata",                                       month:$("#search_month").val(),                                       year:$("#search_year").val(),                                       export:"excel"                                     ],                              "success":function(json){                                                        fncallback(json);                                                        }                              });                     }); 

could show me correct type ajax?

you have it, bracing on data wrong, should {} rather [] object, this:

$('#exportmod').click(function(){   $.ajax({      datatype: 'json',      type: 'get',      url: 'shows_merchan.php',      data: { action: "searchmodelqp",              jhead: "aadata",              month: $("#search_month").val(),              year: $("#search_year").val(),              export: "excel"            },      success: fncallback    }); }); 

the other change above show can do. don't have quote identifiers words aren't reserved (as long valid...and $.ajax() options are), there's no need anonymous wrapped call function same signature, changed success use callback directly.

there's shortcut above $.ajax() call, $.getjson():

$('#exportmod').click(function(){   $.getjson('shows_merchan.php',              { action: "searchmodelqp",               jhead: "aadata",               month: $("#search_month").val(),               year: $("#search_year").val(),               export: "excel" },              fncallback); }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -