tags:

views:

1274

answers:

2

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?

+2  A: 

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");
strager
+1  A: 

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
      });
redsquare