How to return the result from JSONP call outside the function?

You simply cannot do this You have to rewrite your code flow so that AddSecurityCode takes a callback parameter (i.e. A function to run) that you then invoke inside your success callback: function AddSecurityCode(securityCode, token, callback) { $. Ajax({ .... success: function(json) { alert(json); //Alerts the result correctly callback(json); // HERE BE THE CHANGE } .... }); }.

You simply cannot do this. You have to rewrite your code flow so that AddSecurityCode takes a callback parameter (i.e. A function to run) that you then invoke inside your success callback: function AddSecurityCode(securityCode, token, callback) { $.

Ajax({ .... success: function(json) { alert(json); //Alerts the result correctly callback(json); // HERE BE THE CHANGE } .... }); }.

Thanks, seems this is like the only way, I was going to call a function inside success, and chain calling like that, but passing a function like you did is more cleaner. – Adel Aug 27 '09 at 18:29.

You have res declared inside the function, making it's scope local to that function. So there's a start. Declare res outside the function and see what happens.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions