0
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 i put breakpoint on 1st line of success of this jquery success callback, i am unable to access 'searchUrl' in console. It is undefined.

How do i access this?

Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98
  • Have you closed your success function() because in your code I couldn't find the success function is been closed!! – lost_in_magento May 09 '16 at 07:57
  • It is closed. I have just written basic thing. Rest all is working fine, just that i am not able to access input parameter-searchUrl inside success – Sahil Sharma May 09 '16 at 07:59

1 Answers1

0

That's probably because Ajax is asynchronous: the code from the function is executed parallel from the code in the ajax call.

Take a look to this answer for the solution to your problem.

Community
  • 1
  • 1