I made an ajax request (in the admin html) and got the following response:
"{"error":true,"message":"You entered an invalid Secret Key. Please refresh the page."}"
new Ajax.Request('getAjaxExportUrl() ?>', { method: 'get', parameters: { "store" : "someStore" }
.
public function getAjaxExportUrl() { return $this->getUrl('someURL'); }
What's wrong?
1 Answer 1
Magento is using secure key validation in admin aria.
Simplest way to use secure key is use POST and add form_key to data. Example:
jQuery.ajax( {
url: 'http://mage.dev/admin/vendor/module/validateTest',
data: {form_key: window.FORM_KEY},
type: 'POST'
}).done(function(a) {
console.log(a); // log: {a: "b"}
});
-
Do you know why this fails ? magento.stackexchange.com/questions/103068/…Lachezar Raychev– Lachezar Raychev2016年02月23日 16:01:43 +00:00Commented Feb 23, 2016 at 16:01
-
May be your admin URL doesn't have secure key in it. magento.stackexchange.com/questions/104069/…Mukesh Chapagain– Mukesh Chapagain2016年05月08日 08:26:11 +00:00Commented May 8, 2016 at 8:26
Explore related questions
See similar questions with these tags.