jquery - Ajax Call Custom Model Binder returning FormData in URL -


i have created custom model binder complex collection posting via ajax. , good, until return jsonresult page, entire formdata appended url. there small missing here?

i have ajax post form.

  $(document).ready(function() {    $("#savebutton").click(function(e) {     var form = $("#myform");     $.ajax({         type: "post",         url: '/mycontroller/saveall',         data: form.serialize(),         datatype: "json",         error: function(xhr) {             console.log('error: ' + xhr.statustext);         },         success: function(result) {             console.log(result);         },         async: true     }); }); 

});

the controller action.

      public jsonresult saveall([modelbinder(typeof(custommodelbinder))]provincelistviewmodel model)     {            // process             return this.json(new             {                 sucess = true             }, jsonrequestbehavior.allowget);      } 

here custom model binder use request.formdata

 public class custommodelbinder : defaultmodelbinder {     private namevaluecollection _formcollection;      public override object bindmodel(controllercontext controllercontext, modelbindingcontext bindingcontext)         {             if (bindingcontext.modeltype == typeof(provinceviewmodel))             {                 httprequestbase request = controllercontext.httpcontext.request;                  // set form collection                  this._formcollection = request.form;                   // build view models, parse form collection                   // return tab container view model                 return new provinceviewmodel();                }             else             {                 return base.bindmodel(controllercontext, bindingcontext);             }         }  } 

the result url has form data appended it. how prevent this? in advance. _requestverificationtoken=pk4yyr1fth15rphqwe883nlvolho7llwl7cdh_3jp0lq8sxhkgvohq7imubuf-xr6sop5dimbvmpvcpua1rsgt616x3tub4dk57vcgz4-oo1&myid=

try modifying post this:

 $.ajax({         type: "post",         url: '/mycontroller/saveall',         data: {'data':form.serialize()},         datatype: "json",         error: function(xhr) {             console.log('error: ' + xhr.statustext);         },         success: function(result) {             console.log(result);         },         async: true     }); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -