在ASP.NET中不会触发Ajax调用 [英] Ajax call is not fired in ASP.NET

查看:103
本文介绍了在ASP.NET中不会触发Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的专家,



我在使用global.asax中的MapPageRoute代码时,对ajax post call的使用有疑问。



我会告诉你一些我用过的例子。



在Global.asax文件代码中看起来像这样。 />


 protected void Application_Start(object sender,EventArgs e)
{

RouteTable.Routes.MapPageRoute( ICPDR,InitialClaimReport,〜/ Accounts / PC / Initial_Claim_Report.aspx);

}









和Js文件看起来像这样。





 $。ajax({
dataType:'json',
contentType:application / json; charset = utf-8,
type:POST,
url:InitialClaimReport / populate_User /,
data:{},
success:
function(json){

$('#ddl_User')。find ('option')。remove();
$(#ddl_User)。append('< option value =0>< / option>');
$ .each (JSON.parse(json.d).list,function(key,val){

$(#ddl_User)。append('< option value ='+ val.ID + '>'+ val.User +'< / option>');


});

},
错误 :function(xhr,status,p3,p4){
var err =Error++ status ++ p3 ++ p4;
if(xhr.responseText&& xhr.responseText [0] =={)
err = JSON.parse(xhr.responseText).message;
alert(错误);
}
});







在守则背后





 [WebMethod(EnableSession = true)] 
公共静态字符串populate_User()
{

尝试
{
BLL_Users objusr_BLL = new BLL_Users();
return objpractice_BLL.Fetch_UserList();

}
catch(exception ex)
{

throw;
}



}







我使用了上面的代码,但是我的Ajax调用不是在调用。



你可以在使用路由时帮我使用ajax调用asp.net(不是MVC)



谢谢

Dileep ..



我尝试了什么:



我已经尝试了上面的代码,但它无法正常工作。请告诉我有什么问题。

当我尝试时我得到以下错误...





 POST http:// localhost:7777 / InitialClaimPendingDetailReport / populate_practice 404(Not Found)

解决方案

.ajax( {
dataType:'json',
contentType:application / json; charset = utf-8,
type:POST,
url:InitialClaimReport / populate_User /,
data:{},
success:
function(json){


( '#ddl_User')。find('option')。remove();


(#ddl_User)。append('< option value =0>< /选项>');

Dear Experts,

I have a question regarding the usage of ajax post call while using the MapPageRoute code in global.asax .

I'll show you some example that i have used.

In the Global.asax File Code looks like this.

protected void Application_Start(object sender, EventArgs e)
       {

           RouteTable.Routes.MapPageRoute("ICPDR", "InitialClaimReport", "~/Accounts/PC/Initial_Claim_Report.aspx");

       }





And in the Js File Look like this.


$.ajax({
       "dataType": 'json',
       "contentType": "application/json; charset=utf-8",
       "type": "POST",
       "url": "InitialClaimReport/populate_User/",
       "data": {},
       "success":
           function (json) {

               $('#ddl_User').find('option').remove();
               $("#ddl_User").append('<option value="0"></option>');
               $.each(JSON.parse(json.d).list, function (key, val) {

                   $("#ddl_User").append('<option value="' + val.ID + '">' + val.User+ '</option>');


               });

           },
       "error": function (xhr, status, p3, p4) {
           var err = "Error " + " " + status + " " + p3 + " " + p4;
           if (xhr.responseText && xhr.responseText[0] == "{")
               err = JSON.parse(xhr.responseText).message;
           alert(err);
       }
   });




And in the Code behind


[WebMethod(EnableSession = true)]       
        public static string populate_User()
        {

            try
            {
                BLL_Users objusr_BLL = new BLL_Users();                
                return objpractice_BLL.Fetch_UserList();

            }
            catch (Exception ex)
            {
                
                throw;
            }



        }




I have used the above code but My Ajax call is not woking.

Can you please help me to the use of the ajax call while using the routing in asp.net (Not MVC)

Thanks
Dileep..

What I have tried:

I have tried the above code and it is not working. please advise me what is wrong.
When i tried i got the error below...


POST http://localhost:7777/InitialClaimPendingDetailReport/populate_practice 404 (Not Found)

解决方案

.ajax({ "dataType": 'json', "contentType": "application/json; charset=utf-8", "type": "POST", "url": "InitialClaimReport/populate_User/", "data": {}, "success": function (json) {


('#ddl_User').find('option').remove();


("#ddl_User").append('<option value="0"></option>');


这篇关于在ASP.NET中不会触发Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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