How to pass multiple parameters in a single Ajax function?

Jquery callback: access to javascript variables other than callback parameters?

  • From withing jquery callback method (such as success or error callback function, for example, in case of jquery ajax get request), how can I access variables other than callback function's parameters. In other words if I have a javascript variable - say, var error_message="blah ..." - how can I access it in an ajax callback - say complete: function(XMLHttpRequest, textStatus). In this particular case, I have access to only two variables - XMLHttpRequest and textStatus. How can I access other javascript variables - say a string variable defined elsewhere?

  • Answer:

    I seem to have access to everything from the callback, even variables defined elsewhere. Make sure the variables you wanna access are within the scope of the callback, not within some other function.

r_b28 at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

What Khalid said is exactly right. Ensure that you're attempting to call a string or variable described within your function, and script. You cannot call or define variables from other functions / scripts, without writing a script to do just such that. XMLHttpRequest does this for you, but not in the scope or capacity that you desire.

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.