javascript - How to send Json data and textbox data through jQuery ajax -


i have json collection , want send 1 textbox value controller through jquery ajax

 $('#btnsave').click(function (e) {     debugger;     $.ajax({         type: "post",         url: '/asset/saveassociate',         data: "{'data':'"+json.stringify(allvals)+"'}",         contenttype: "application/json; charset=utf-8",         datatype: "json",         success: function (data) {             alert(data);          //   var gridk = $("#grid1").data("kendogrid");           //  gridk.datasource.read();         }     }) }) 

and textbox value

 var _assetid = $("#assetid").val().trim(); 

like data: { json , assetid :assetid } can pass this

this action method

[nocache] public actionresult saveassociate(string data, string assetid) {             javascriptserializer json = new javascriptserializer();             list<getuserdata> myobjs = new list<getuserdata>();             myobjs = json.deserialize<list<getuserdata>>(data);              (int = 0; <= myobjs.count; i++)             {             }              return content("hai"); } 

i believed, want

 $('#btnsave').click(function (e) {         debugger;         var datatosend={           'data':json.stringify(allvals),           'assetid':$("#assetid").val().trim()         };         $.ajax({             type: "post",             url: '/asset/saveassociate',             data: json.stringify(datatosend),             contenttype: "application/json; charset=utf-8",             datatype: "json",             success: function (data) {                 alert(data);              //   var gridk = $("#grid1").data("kendogrid");               //  gridk.datasource.read();             }         })     }) 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -