ajax - jquery on success to process data returned from the server -


i sending jquery $.ajax(); request server, , want onsuccess function work according params sent server rather params received server because each time site supposed behave depending on sent, rather received how attach "sent" parameters, without making them global onsuccess function ?

this function :

 $.ajax({             url : this.soaptarget,             type : "post",             datatype : "xml",             data : this.soapmsg,             processdata : false,             beforesend : function(xhr) {             xhr.setrequestheader("soaptarget",this.soaptarget);             xhr.setrequestheader("soapaction",this.soapaction);             },             contenttype : "text/xml; charset=\"utf-8\"",             success : onsuccess,             error : onerror             }); 

when function parameter in more global function , why has "this.soapmsg" , this.soaptarget , this.soapaction parameters

in onsuccess function want use "this" object display result on web page

how do that?

try this,

var self=this; $.ajax({     url : this.soaptarget,     type : "post",     datatype : "xml",     data : this.soapmsg,     processdata : false,     beforesend : function(xhr) {         xhr.setrequestheader("soaptarget",this.soaptarget);         xhr.setrequestheader("soapaction",this.soapaction);     },     contenttype : "text/xml; charset=\"utf-8\"",     success : function(){         $(self).html('your data goes here'); // self points object     },     error : onerror  }); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -