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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -