javascript - jquery unable to access function parameter inside function with an ajax call? -


hiturl = function (searchurl, nbcity) {     $.ajax({         context: this,         type: 'get',         headers: { "sourceid": "1" },         url: '/webapi/xyz/abc/?' + searchurl,         datatype: 'text',         success: function (json) {             d_usedsearch.similarcars.showsimilarcarlink(searchurl);  }); 

when put breakpoint on 1st line of success of jquery success callback, unable access 'searchurl' in console. undefined.

how access this?

that's because ajax asynchronous: code function executed parallel code in ajax call.

take this answer solution problem.


Comments