Does jQuery ajaxSetup method not work with $.get or $.post?
Posted
by Justin Poliey
on Stack Overflow
See other posts from Stack Overflow
or by Justin Poliey
Published on 2010-03-30T04:55:38Z
Indexed on
2010/03/30
5:03 UTC
Read the original article
Hit count: 579
Does the jQuery $.ajaxSetup
method not respect the data
field in the options hash when $.post
or $.get
is called?
For example, I might have this code:
$.ajaxSetup({ data: { persist: true } });
Then, to send a POST request, I would call this:
$.post("/create/something", { name: "foo" });
I was expecting the actual POST data to look like this:
{
persist: true,
name: "foo"
}
but the only data sent by $.post
is { name: "foo" }
. Is there any way to get the expected behavior? I'm using jQuery 1.4.1.
© Stack Overflow or respective owner