javascript - jquery ajax callback function without dynamic parameters -
I have an array with objects, I want to save them every one through GET, and some in the callback I want to update the parameter, Bot
the html:
& lt; Html & gt; & Lt; Body & gt; & Lt; Div id = 'test' & gt; & Lt; Div id = "a" & gt; A & lt; / Div> & Lt; Div id = "b" & gt; B & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;
JS:
$ Save the map ($ ("# test> gt"), save) = save function (o, i) {itt = $ (o) tmp = {'desc': itt.html ()}; $ .get ('ajax / update_post', {'data': array2json (tmp)}, function (a) {warning (itt.attr ('id')) Update postback (a, itt)}) updatePostBack = function A, item) {Warning (item.attr ('id')}
Update postback is always getting las item! I can call the correct ID or object in the callback function in js / jquery How can I pass?
The solution is so unfortunate worldly: in front of your variable < Need to add code> var so that they can be redesign The first one can be completed before they were overwritten unsuitable during the next visit. This code works for me:
save = function (o, i) {Var itt = $ (o) var tmp = {'desc': itt.html ()}; $ .get ('ajax / update_post', {'data': array2json (tmp)}, function (a) {warning (Itt.attr ('id')) Update Postback (a, itt)}} updatePostBack = function (A, item) {warning (item.attr ('id') $ .map ($ ("# test" ; Div "), save);
I have also transferred the map statement to the end so that it was declared after that by calling the saved function.
Comments
Post a Comment