Set Session Variable

I have a form that has a button that on click makes an ajax call to a webservice that returns an entityobject.  How can i pass a value from the returned object to a session variable?  I am using jquery.ajax().
ikeyserAsked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
Example :


$(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "WebService.asmx/HelloWorld",
            dataType: "html",
            data: "name=value",
            contentType: "html",
            success: function (data) {
                // do something with data here
                setSessionVar("HelloKey", "WorldValue");
            },
            error: function (data) {
                alert("error : " + data);
            }
        })
    });

    function setSessionVar(key, value) {
        $.ajax({
            type: "POST",
            url: "WebService.asmx/setSV",
            dataType: "html",
            data: encodeURIComponent(key) + "=" + encodeURIComponent(value),
            contentType: "html",
            success: function (data) {
                alert(data);
            },
            error: function (data) {
                alert("error : " + data);
            }
        })
    }

Open in new window

0
 
leakim971PluritechnicianCommented:
>How can i pass a value from the returned object to a session variable?

A new ajax call ? Or if possible, set it in the web service
0
 
ikeyserAuthor Commented:
Can you provide an example?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
leakim971PluritechnicianCommented:
0
 
ikeyserAuthor Commented:
Thank you for the link but it doesn't provide an example of how I can pass data I get back from the ajax call.
0
 
Samuel LiewCommented:
You will have to make a second AJAX call to a server-side page to set the session variable.
0
 
ikeyserAuthor Commented:
Example please
0
 
leakim971PluritechnicianCommented:
Thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.