sherbug1015
asked on
Passing a variable out of an ajax call
I have some Jquery like this that is not working.
var roomid = 0;
$.ajax({
type: "POST",
url: "/CMSPages/WebService.asmx /GetChatRo omId",
data: {RecipientId : recipientid},
success: function (data) {
var encodedHtml = data.children[0].innerHTML ;
var decodedHtml = decode(encodedHtml);
}
});
roomid = decodedHtml;
decodedHtml has not value outside of the ajax call. How can I get that value out to the roomid variable.
Thanks.
var roomid = 0;
$.ajax({
type: "POST",
url: "/CMSPages/WebService.asmx
data: {RecipientId : recipientid},
success: function (data) {
var encodedHtml = data.children[0].innerHTML
var decodedHtml = decode(encodedHtml);
}
});
roomid = decodedHtml;
decodedHtml has not value outside of the ajax call. How can I get that value out to the roomid variable.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set the roomid value directly into response function:
(This is evaluated asynchronously after POST is done)
Open in new window