I am developing a WP plugin. I have two same AJAX calls, one is working, and second one is giving me 400 Bad Request error for admin-ajax.php.
ReadyState is 4, responseText is: "
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵0", statusText is "Bad Request", error is POST http://localhost/wc_addtocart_as_admin/wp-admin/admin-ajax.php 400 (Bad Request)
Both calls are getting data from two separated <form>
elements. When I change data
in working AJAX to use array defined in js code, like in example below, it gives me the same error like the second AJAX call which is not working at all.
var test = [];
test[0] = {name: "reason", value: 'OLALA'};
test[1] = {name: "second", value: 'TRUS'};
jQuery.ajax({
url: test_ajax_object.ajax_url,
type: 'POST',
data: test
etc...
})
So, only first AJAX works with first <form>
data. And second one, which is absolutely the same, doesn't.
What could be possible reasons for this weird behavior? Please let me know if I should provide some more info.