Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I'm trying to refresh my web page with a webmethod because I want to update an oracle databases and refresh a table in my web page.
I'm truing to do it with jQuery ajax() but I don't know "how to make a postback". DO you know please ?
This is my current code :
JavaScript
$.ajax({
        type: "POST",
        data: "{ request : " + JSON.stringify(listeIdEntiere) + "}",
        url: "Test.aspx/doAssignation",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
        },
        error: function () {
            alert("BAD");
        }
    })

C#
[WebMethod]
public static string doAssignation(string request)
{
    return request;
}


Thanks
Posted
Updated 22-May-13 0:36am
v2
Comments
Requirement is not clear. If you are using a Web Method that means you are using ajax functionality. Then you can return what ever value you want from that method and in success method you can assign that to the table. So, the table will have new values.

What is the problem ? Please explain more about the requirement.
trevesTrainee 22-May-13 7:55am    
Thanks, I don't think about this solution lol
So, what solution you think to implement ?
trevesTrainee 22-May-13 10:06am    
I don't know for the moment because a static WebMethods can't access to Session and I need Session to do my work :'(
jkirkerx 22-May-13 22:53pm    
Does your test.aspx page exist?, should be a asmx page

You should call the page directly and make sure it works first, you should get a textbox that you enter the value into.

Then work on the jquery side

In your success function of jQuery's .ajax() method, add

JavaScript
location.reload(true);


This JavaScript will cause the page to reload. It won't postback, but from what you described you just want it to refresh and not postback. They are different.
 
Share this answer
 
HI,
TO do this you have to employee a ashx handler .
Inside the ashx handler call the web service.
write in to the response stream of the http request.
Call the handler with the help of Jquery AJax
You will get response in the JQuery ajax Success.
why i suggested the handler is that you mentioned that you also want to make use of session,if you implement an inter face called
C#
IReadOnlySessionState

then you can use session in http handler.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900