views:

1156

answers:

3

I have few input fields in a form. after some validation, I use jquery to post the page.

$.post("Myproduct.aspx?action=1");

The post appears to go through. But when I debug the server code, the request.form[] is null.

Has any one had this problem?

+6  A: 

if the

$.post("Myproduct.aspx?action=1");

is the only thing that is being posted, then no wonder, because you are simply missing the post parameters (the second parameter in the $.post() function). You probably want something like this:

var post_data = { 'key':'value', 'key2':'value2' } //or just some sort of data reading from a form
$.post("Myproduct.aspx?action=1",post_data);
Ramuns Usovs
A: 

Okay, so the doc for this is at http://docs.jquery.com/Ajax/jQuery.post

$.post(url, data, callback, type)

This is how $.post looks, the first parameter the url is required the second where you put the data is not. So if you want to post some data you would do add an object:

$.post("Myproduct.aspx?action=1", {"key1": data1, "key2": data2});

If you are doing this cross domain you would need to use JSONP, but that requires some extra work, both on the javascript and how the server returns the data.

googletorp
A: 

You should check out the JQuery Forms plugin. It will handle all the dirty work of building the data parameter for you from your form. Super fast, and easy as can be.

smercer