Reputation: 875
Sample Code:
function GetEmployee(Id, callback) {
return $.ajax({
...
...
success: function(data) {
if(data.success == 1)
callback('1');
else
callback('2');
},
...
});
}
Let's say this particular JQuery code is executing in my Firefox in the tab '2' of my machine (client), once it sees the ajax call, the call will be made to web server and once the request has been processed by the web server, it will send this response back to my machine (client).
Now, WHO will be listening for the server response and bring this response into my callback method? I mean, identifying Firefox and its tab number and the callback method( success: function(data)). Thanks for reading.
Upvotes: 3
Views: 128
Reputation: 27012
I'm not sure I entirely understand the question, or rather what you're asking for. Ensuring that the response comes to the right place is handled for you, so unless you're asking from an academic standpoint, you don't need to worry about it.
As for your other question, "Now who can I bring this response into my callback method?" you should be able to pass the response data to your callback as a parameter:
callback(data);
It may help to see the code that calls GetEmployee()
.
Upvotes: 1
Reputation: 365
Your question in itself doesn't really seem to make lots of sense. You cannot make cross-tab calls, therefore you need not worry about that at all. The callbacks are really just functions like any other, same goes for your ajax calls.
Upvotes: 1