3
$(document).ready(function () {
    $("button").click(function () {
        getData();
    });
});

function getData() {
    var promise = testAjax('example2.aspx');
    displaySTSummaryData(promise);
}

function testAjax(theURL) {
    var person = {
        Name: 'happy',
        age: '21'
    };
    return $.ajax({
        url: theURL,
        type: 'POST',
        data: person
    });
}

function displaySTSummaryData(x) {
    x.success(function result(data) {
        $("div").html(data);
    });
}

In the above code I am sending data to example2.aspx. I can use only jquery aspx ajax. How can i display details of (Person (being sent ) on example2.aspx.

7
  • Specify your function which is take the parameter named as Name:'' And Age Commented Apr 25, 2014 at 9:43
  • thats what i need to know. I am very new to asp. Do i need to define a function in code behind of exampl2.aspx? I tried response.direct and querystring but the ajax does not work Commented Apr 25, 2014 at 9:45
  • Please refer this code and apply to your according aspsnippets.com/Articles/… Commented Apr 25, 2014 at 9:49
  • thanks nayeem that is good code to refer. Commented Apr 25, 2014 at 10:31
  • I will definitely keep you updated. just halfway through. Commented Apr 25, 2014 at 10:38

3 Answers 3

0

I would erase displaySTSummaryData function and add:

function testAjax(theURL) {
     var person = { Name: 'happy', age: '21' };
     return $.ajax
     ({
         url: theURL,
         type: 'POST',
         data: person
         success: function(e){
             $("div").html(e);
         }
      });
}
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for not making it clear. I can populate data in my example.aspx where ajax is defined. I need to display the same data in example2.aspx.
0

You can only call a static function in .aspx. Use like

function testAjax(theURL) {
    var person = {
        Name: 'happy',
        age: '21'
    };
    $.ajax({
        url: "example2.aspx/GetData",
        type: 'POST',
        data: person,
        success: function (data) {
            $("div").html(data);
        }
    });
}

In aspx,

public static string GetData(string Name, int age) {
    return "Name :" + Name + ",Age:" + age;
}

You can use the success event of ajax to populate the data.

Comments

0

Try this one

function displaySTSummaryData(x) {
    x.done(function (data) {
        $("div").html(data);
    });
}

4 Comments

sorry but it does not help.
function getData() { var promise = testAjax('example2.aspx'); promise.done(function (e) { $("div").html(e); });}
it does not make any difference
Basically on document.ready(function) of example2.aspx i want to display the details of person, which i am sending from ajax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.