TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anilananda Chakrabortty
NA
425
78k
storing value after Ajax function calling
Feb 28 2019 6:33 AM
Hy guys i stuck in storing value to a variable after calling ajax method , i am not able to use
callback in ajax....
Someone help me please...
here is the code===============
var s = GetSessionValue("userId");
alert(s);
function GetSessionValue(key1) {
$.ajax({
type: "POST",
url: "Service1.asmx/GetSessionValue",
data: '{key: "' + key1 + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
function OnSuccess(result) {
return result.d;
alert(result.d);
}
}
===============================
AJAX methods are calling sucessfully , data also getting correct...
but i want to return the value from ajax function and want to store in another variable .
In my existing code
var s = GetSessionValue("userId");
alert(s);
Im getting undefind value.
I know some callbak logic is required , but im not able to implement in this case ....
i need someone help ...
Thanks
Reply
Answers (
5
)
What is the error in this code
Ajax function always calling error function