在一般處理程序(ashx)中彈出js提示語
在提交form表單時,比如前臺是$("form").submit()同步提交的時候,這個是沒有回掉函數(shù)的,那么我們只能在后臺提示,在前臺顯示,自己作為一個參考吧
public class Script
{
public static void Alert(string message)
{
ResponseScript("alert('" + message + "');window.location = '彈出提示語后,點擊確認(rèn)跳到你想跳的頁面';");
}
public static void ResponseScript(string script)
{
HttpContext.Current.Response.Write("<script type=\"text/javascript\">\n//<![CDATA[\n");
HttpContext.Current.Response.Write(script);
HttpContext.Current.Response.Write("\n//]]>\n</script>\n");
}
}
還有就是將一般處理程序默認(rèn)的 //context.Response.ContentType = "text/plain";改為
context.Response.ContentType = "text/html";
我們調(diào)用的時候直接:
Script.Alert("你的提示語!");
PS:Js中$.ajax調(diào)用一般處理程序(.ashx)
$.ajax({
type: "post",
url: "/tools/ActApply.ashx",
data: "txthdmoney=" + $.trim($("#hdmoneyx")[0].value)+"&sxf=2",
success: function (result) {
}
});
.ashx后臺接收數(shù)據(jù)
protected decimal hdmoney;
protected decimal hdsxf;
/// <summary>
/// 請求處理
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
Withdrawal withdra = new Withdrawal();
context.Response.ContentType = "text/plain";
hdmoney = Convert.ToDecimal(context.Request.Params["txthdmoney"].ToString());
hdsxf = Convert.ToDecimal(context.Request.Params["sxf"].ToString());
SaveAct();
}
public bool IsReusable
{
get
{
return false;
}
}
總結(jié)
以上所述是小編給大家介紹的在一般處理程序(ashx)中彈出js提示語,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
JavaScript 一行代碼,輕松搞定浮動快捷留言-V2升級版
前天熬了大半宿發(fā)了一篇[一行代碼輕松搞定快捷留言功能],同時發(fā)布了V1.0beta版的快捷留言功能和源代碼,之所以是beta版,就是當(dāng)時感覺雖然基本功能有了,但是還不夠完善,特性也不一定合理2010-04-04
解決layer彈出層的內(nèi)容頁點擊按鈕跳轉(zhuǎn)到新的頁面問題
今天小編就為大家分享一篇解決layer彈出層的內(nèi)容頁點擊按鈕跳轉(zhuǎn)到新的頁面問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09
JavaScript使用WebSocket實現(xiàn)實時通信的技術(shù)詳解
WebSocket作為一種高效的通信協(xié)議,為開發(fā)者提供了一種在客戶端和服務(wù)器之間進行全雙工通信的方法,本文將深入探討WebSocket技術(shù),并提供實戰(zhàn)代碼示例2024-04-04

