Solved

Set Session Variable

Posted on 2010-09-02
8
1,255 Views
Last Modified: 2012-05-10
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().
0
Comment
Question by:ikeyser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 33592901
>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
 

Author Comment

by:ikeyser
ID: 33592915
Can you provide an example?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33592946
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

Author Comment

by:ikeyser
ID: 33592994
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
 
LVL 14

Expert Comment

by:sam2912
ID: 33593066
You will have to make a second AJAX call to a server-side page to set the session variable.
0
 

Author Comment

by:ikeyser
ID: 33593089
Example please
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 33593117
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
 
LVL 82

Expert Comment

by:leakim971
ID: 33593154
Thanks for the points!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question