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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
sam2912Commented:
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
All Courses

From novice to tech pro — start learning today.