2013-08-19 53 views
2

我有以下的jQuery函数JQuery的发布网址

function refreshTheGrid(myData, ceduleDateFrom, ceduleDateTo, paramOrderNo) { 



    var myData2 = { 
     CeduleDateFrom: ceduleDateFrom, 
     CeduleDateTo: ceduleDateTo, 
     ParamOrderNo: paramOrderNo 
    }; 


    var theUrl = "UpdateCheckBox"; 
    var theUrl2 = ""; 

    $.ajax({ 
     type: "POST", 
     url: theUrl, 
     data: myData, 
     dataType: "text", 
     success: function (data) { 
      $.ajax({ 
       type: "POST", 
       url: theUrl2, 
       data: myData2, 
       dataType: "text", 
       success: function (data) { 
        $('#monbouton').click(); 
       } 
      }) 
     } 
    }) 
    popup.Hide(); 
    void (0); 
} 

我的应用程序是http://localhost/JprMvc/

当我POST方法是通过Fiddler2

POST /JprMvc/CeduleGlobale/UpdateCheckBox HTTP/1.1 

叫下面是捕获
POST /JprMvc/ HTTP/1.1 

直到我从我的URL中删除CeduleGlobale部分之前,我遇到了问题。现在一切正常。

我认为这是一个路由问题,但我不确定。

我的路由是

routes.MapRoute(
       "Default", // Route name 
       "{controller}/{action}/{id}", // URL with parameters 
       new { controller = "CeduleGlobale", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
      ); 

它现在,但似乎武断。

我应该从我的路由中删除默认值,并把它放回jQuery中。

我在想什么?

回答

3

我通常将路由作为默认值,并在jQuery调用中更改控制器。

路由代码

routes.MapRoute(
       "Default", // Route name 
       "{controller}/{action}/{id}", // URL with parameters 
       new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
      ); 

jQuery代码

$.ajax({ 
     type: 'GET', 
     dataType: 'json', 
     timeout: 300000, //5 minutes (in milliseconds) 
     url: '/YourApplicationName/YourContollerName/YourMethodName', 

//... 
+0

的myData的是在函数调用中传递的参数,mydata2是如在第二函数调用中的参数传递一个简单的数据,这是由设计。 – SerenityNow

+1

我更新了我的答案以删除不正确的部分。 – JabberwockyDecompiler

+1

问题是我的应用程序没有家庭控制器。家是CeduleGlobale。这是一个大否不? – SerenityNow