如何在web方法中进行回发 [英] How to make a postback in a webmethod

查看:102
本文介绍了如何在web方法中进行回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在尝试使用webmethod刷新我的网页,因为我想更新oracle数据库并刷新网页中的表格。

我很想用jQuery ajax()来做这件事,但我不知道如何回发。你知道吗?

这是我目前的代码:

 $。ajax({
type: POST
data: < span class =code-string> {request: + JSON .stringify(listeIdEntiere)+ }
url: Test.aspx / doAssignation
contentType: application / json; charset = utf-8
dataType: json
成功: function (msg){
alert(msg.d);
},
错误: function (){
alert( BAD);
}
})



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





谢谢

解决方案

.ajax({
类型: POST
data: {request: + JSON .stringify(listeIdEntiere)+ < span class =code-string> }
url: Test.aspx / doAssignation
contentType: application / json; charset = utf-8
dataType: json
成功: function (msg){
alert(msg.d);
},
错误: function (){
alert( BAD);
}
})



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





谢谢


在jQuery的成功函数中。 ajax()方法,添加



  location  .reload( true ); 





此JavaScript将导致页面重新加载。它不会回发,但从你所描述的你只是想要它刷新而不是回发。它们是不同的。


HI,

要做到这一点,你必须雇用一个ashx处理程序。

在ashx处理程序内部调用网络服务。

写入http请求的响应流。

在Jquery AJax的帮助下调用处理程序

您将获得响应JQuery ajax成功。

为什么我建议处理程序是你提到你也想要使用session,如果你实现了一个名为

 IReadOnlySessionState  

然后你可以在http处理程序中使用session。


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 :

$.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");
        }
    })


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



Thanks

解决方案

.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"); } })


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



Thanks


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

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.


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

IReadOnlySessionState


then you can use session in http handler.


这篇关于如何在web方法中进行回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆