JSON脚本没有重定向asp.net中的页面 [英] JSON script is not redirecting the page in asp.net
本文介绍了JSON脚本没有重定向asp.net中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用下面的脚本,但它没有重定向页面。
Hi all,
I am using the script below but it s not redirecting the page.
string rdpConnect = "function btnShowID_onclick(){" +
"if(document.getElementById('MainContent_ctl00_txtBeginDateID').value!='' && document.getElementById('MainContent_ctl00_txtEndDateID').value!='' && document.getElementById('MainContent_ctl00_ddlAuditorsID').value!='' )" +
"{" +
//"alert($('#ContentPlaceHolder1_ucSample_txtName').val());" +
"$.ajax({type: 'POST'," +
"url: '~/WebService.asmx/Navigatetopage'," +
"data: '{zip:jhg}'," +
"contentType: 'application/json; charset=utf-8'," +
"dataType: 'json'," +
"success: function(msg) {" +
"if(msg.d=='True'){" +
//"window.location.href='~/ReportPage/ReportViewerForAll.aspx?&ReportName=" + _reportName + "';" +
"window.location.href='Default.aspx'"+
"}" +
"}" +
"});" +
"}" +
"else" +
"{" +
"alert('Please Enter The Required Field(s)');" +
"return false;" +
"}" +
"}";
rdpFunctions.InnerHtml = rdpConnect;
this.Controls.Add(rdpFunctions);
flag = false;
}
非常感谢任何想法或帮助。
提前致谢
Shafik
Any idea or help is higly appreciated.
Thanks in advance
Shafik
推荐答案
('#ContentPlaceHolder1_ucSample_txtName')。val()) ;+
('#ContentPlaceHolder1_ucSample_txtName').val());" + "
.ajax( {type:'POST', +
url:'〜/ WebService.asmx / Navigatetopage', +
data:'{zip:jhg}', +
contentType:'application / json; charset = utf-8', +
dataType:'json', +
< span class =code-string> success:functio n(msg){ +
if(msg.d =='True' ){ +
// window.location.href ='〜/ ReportPage / ReportViewerForAll.aspx?& ReportName =+ _reportName +';+
window.location.href ='Default.aspx' +
} +
} +
}); +
} +
else +
{ +
警告('请输入必填字段'); +
return false; +
} +
};
rdpFunctions.InnerHtml = rdpConnect;
this .Controls.Add(rdpFunctions);
flag = false ;
}
.ajax({type: 'POST'," + "url: '~/WebService.asmx/Navigatetopage'," + "data: '{zip:jhg}'," + "contentType: 'application/json; charset=utf-8'," + "dataType: 'json'," + "success: function(msg) {" + "if(msg.d=='True'){" + //"window.location.href='~/ReportPage/ReportViewerForAll.aspx?&ReportName=" + _reportName + "';" + "window.location.href='Default.aspx'"+ "}" + "}" + "});" + "}" + "else" + "{" + "alert('Please Enter The Required Field(s)');" + "return false;" + "}" + "}"; rdpFunctions.InnerHtml = rdpConnect; this.Controls.Add(rdpFunctions); flag = false; }
非常感谢任何想法或帮助。
提前致谢
Shafik
Any idea or help is higly appreciated.
Thanks in advance
Shafik
如果条件为真,但ajax调用是否成功怎么办?这不会显示。尝试为错误情况添加代码,如下所示:
What if the condition is true, but the ajax call isn''t a succes? This would not show. Try to add code for the error situation, like this:
这篇关于JSON脚本没有重定向asp.net中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文