Reputation: 161
I am new to jquery ,so i need some help to make a request to server with post.
Why i have chosen $.post is i have large ammount of data to pass to the server.
I have javascript variables like action="Next",resultData=""(this is the very large string). So how to pass this javascript varaiables to $.post?
Thanks.
Upvotes: 1
Views: 287
Reputation: 20765
It's all defined in the man page for it
$.post
is just an alias of $.ajax
. I would suggest using $.ajax
instead just because you have more control and it's more maintainable in the long run.
$.ajax({
type: 'POST',
url: url,
data: data,
success: success
dataType: dataType
});
You can either define data in it's var1=data1&var2=data2&var3=data3
string format, or as an object. I suggest using objects because it's eaiser to see and work with.
{
"var1" : "data1",
"var2" : "data2",
"var3" : "data3"
}
Upvotes: 1