ASP.NET AJAX.BeginForm sends multiple requests

前端 未结 3 1021
广开言路
广开言路 2020-12-15 22:04

Im relatevely new with Asp.net MVC3,

I have a form handled with Ajax, like this:

@using (Ajax.BeginForm(\"dtjson\", new AjaxOptions { HttpMethod = \"Post\"

3条回答
  •  死守一世寂寞
    2020-12-15 22:26

    You have included jquery.unobtrusive-ajax.min.js twice once in the layout once in the partial. So your browser executes the js inside twice which will subscribe twice on the form click event that is why doing two POST instead of one.
    So you need to remove the jquery.unobtrusive-ajax.min.js from the partial.

    Note: If your are using a partial with a layout you don't need to duplicate the js included in the partial because it's already done by the layout. There are some good articles about layouts and partials.

提交回复
热议问题