javascript - jQuery Ajax Post.settings vs Get.settings -
i'm trying build mini plug-in.therefore, want minimize code , make stable as be. problem clear observe on code, see below ( detailed explanation below snippet segment):
$(document).ajaxsend(function (event, xhr, settings) { alert("settings data : " + settings.data + " , " + "settings url : " + settings.url ); }); $("#topleftbutton").click(function () { var arr = { "loadingbar": '#topleftload' } $.ajax({ type: "get", url: "testb.xml", data: json.stringify(arr), datatype: "xml", success: function (xml) { }, }); }); $("#toprightbutton").click(function () { var arr = { "loadingbar": '#toprightload' } $.ajax({ type: 'post', url: 'testb.xml', data: json.stringify(arr), datatype: "xml", success: function (xml) { }, }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="button" id="topleftbutton" value="top left"> <div id="topleftload" style="display:none; width:100%; height:60px"> </div> <input type="button" id="toprightbutton" value="top right"> <div id="toprightload" style="display:none; width:100%; height:60px"> </div>
when check documents @ get method , post method, not observe difference between settings,data , url of post & get. however,in post method of above code snippet works great. url , data on exact place should be. whereas, in method data appended url , settings.data shown undefined.
thank cares,
yes did, if compare these 2 methods looking @ parameters, method definitions there not difference, way it's been implemented jquery( , other low level implementations) considerably different.
the appends data url. post send data witihn request body.
hence post more secure get. is either or post more secure other?
also request has pay load limitation. default cannot send data more 8192 bytes (8kb).
maximum length of http request?
hence it's practice use post instead of get
Comments
Post a Comment