I am trying to use jQuery's ajax functionality to update data from a web form (ASP.NET MVC). Part of the data comes from a text area, and while is not a huge amount of data, can easily be more than 2 KB.
It seems that jQuery ajax puts all data into the query string, hence causing IIS to reject the URL, hence breaking the call. Is it possible to add data to a POST request using the ajax model under jQuery, rather than having everything in the query string?
use $.post
e.g
$.post(someUrl, { textData: $('#someInput').val() } );
$.post is just a simple wrapper around $.ajax.
$.ajax({ type :"post",
data : { textData: $('#someInput').val() },
url : someUrl
});
Yes; according to jQuery's documentation, you can use jQuery.post
to POST data.
If you want to post an existing form, use:
var form = $("#myform"); // or whatever
$.post(form.get()[0].action, form.serialize(), function(data) {
// data received
}, "xml");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With