When making an AJAX request is works when my data is a URL style string.
var options = {
type: 'post',
data: 'action=my_action'
};
The function will get called and return some fake data just fine.
If I try to make the same call but use JSON, it doesn't work. I've tried several different ways of doing it, but admin.php just return -1.
Is there something in jQuery or Wordpress that I need to change to allow this?
Here are a couple of the other ways I've tried.
var options = {
type: 'post',
data: { action: 'my_action' }
};
var options = {
type: 'post',
data: JSON.stringify({ action: 'my_action' })
};
The example in the docs have it using a JSON object too. http://codex.wordpress.org/AJAX_in_Plugins