Jude
Jude

Reputation: 2433

Ajax Call fails because of number of arguments

Ajax Call to msgcall method:

PopAjaxPost('mesaj/popup/msgcall/' + i + '/' + $('input#mesajkategori').val(), mysarr, function (data) {
        if (data.Durum == '1') {
            $wrapper.html('<a href="javascript:void(0);" class="all">Mesaj</a><div class="preview"><div class="block"><strong>Gönderen:</strong>'
                + data.Data.Mesaj.Gonderen + '<br /><p>Sayın <strong>' + data.Data.Mesaj.Alici + '</strong></p><p>'
                + data.Data.Mesaj.Mesaj + '</p></div>' + (data.Data.Mesaj.SecenekId > 1 && !giden ? ('<input type="submit" value="Cevapla" onclick="mesajcevapla('
                + data.Data.Mesaj.MesajId + ');return false;" style="margin-bottom: 8px;">') : '') + '</div>');
        }
        else {
        }
    });

Here is msgcall method with three arguments:

[HttpPost]
[AjaxException]
[UserFilter]
public ActionResult MsgCall(string id, string pid, MsgHire model)
{
     ....
}

It does not invoke the msgcall method with the supplied arguments. If I remove the + i + '/', it invokes the msgcall method. What am I doing wrong?

From Route.config:

routes.MapRoute("MesajPopup", "mesaj/popup/{action}/{id}",
            new { controller = "Mesaj", action = "Liste", id = UrlParameter.Optional });
routes.MapRoute("Mesaj", "mesaj/{action}/{id}",
            new { controller = "Mesaj", action = "Liste", id = UrlParameter.Optional });

Upvotes: 0

Views: 39

Answers (1)

AliRıza Adıyahşi
AliRıza Adıyahşi

Reputation: 15866

There is no configuration for additional parameter named pid, so you should define a maproute for this parameter.

Add something like this line:

routes.MapRoute("Msg_Call", "mesaj/popup/{action}/{id}/{pid}",
    new { 
        controller = "Mesaj", 
        action = "Liste", 
        id = UrlParameter.Optional,  
        pid = UrlParameter.Optional 
});

Upvotes: 1

Related Questions