How can I return a JSON result to a Ajax.BeginForm

后端 未结 6 1157
独厮守ぢ
独厮守ぢ 2021-02-02 08:49

I have got this simple form:

@using (Ajax.BeginForm(\"CreateProductFromAjaxForm\",\"Product\" , 
                  null, 
                  new AjaxOptions() {           


        
6条回答
  •  孤街浪徒
    2021-02-02 09:14

    I faced the same issue with my project. Ajax library is not being loaded is the problem. When I checked my bundleconfig and my layout file, it did have the include but I'm including the absolute name for ajax library like

    bundles.Add(new ScriptBundle("~/bundles/jqueryajax").Include(
    "~/Scripts/jquery.unobtrusive-ajax.min.js"));
    

    My friend asked me to use the wild card instead. Surprisingly bundles.Add(new ScriptBundle("~/bundles/jqueryajax").Include("~/Scripts/jquery.unobtrusive-ajax*")); started including the ajax library.

    Now my OnSuccess functions are loading as expected rather than looking at the blank screen with json response on it.

提交回复
热议问题