2

我有以下 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 中吗?

我错过了什么?

4

1 回答 1

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',

//...
于 2013-08-19T18:45:15.513 回答