| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Issue in calling an ajax request in admin area. | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Issue in calling an ajax request in admin area.
Hello, I am X-Cart developer from Webkul Software Private Limited, UP, INDIA.
I have an issue in process of ajax calling in admin area on a page. like: I had created a page with a button at admin area, I want to call a ajax request to click on that button. But when i click on that button to call a function which was already written in the same controller file but an error notice has occurs like below: "The form could not be identified as a form generated by X-Cart. The reason may be that a substantial period of time has elapsed since you opened the page with this form or the page was opened in more than one browser tab. If you did not open the page with this form, you might be under a CSRF attack." So can anyone Please help me. My code are below: 1. In controller File the action is as below. PHP Code:
2. Ajax request is as below: PHP Code:
Here number_demos is the controller which class is NumberDemos
__________________
Ajeet Singh Sr.Software Developer Webkul Software Pvt. Ltd. |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Issue in calling an ajax request in admin area.
The buildURL function doesn't add the form_id parameter that protects backend forms and links from hijacking.
When is your function called? Is there a link or a form on the page that you want to follow/submit? If so, you can get the URL via jQuery, something like this: Code:
Code:
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#3
|
|||||||
|
|||||||
Re: Issue in calling an ajax request in admin area.
Hello qualiteam,
As you suggest about to use admin url i have done same but my issue is remain same. the code is as below : PHP Code:
And the controller function is as below: PHP Code:
In that case the ajax call is done but when i click on the ajax url in console then it redirect on the page where a notice is appear that i have no permission to access that page. I have also provide the snapshot of that page below;
__________________
Ajeet Singh Sr.Software Developer Webkul Software Pvt. Ltd. |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Issue in calling an ajax request in admin area.
Every backend URL is signed with a unique identifier that can be used only once.
As far as I understand you use the same URL twice: the first time you send a background request to that URL, and the second time you try to follow it from the JavaScript console. It won't work this way, unfortunately. As soon as you send an AJAX request, the URL becomes expired and won't work from the console.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#5
|
|||||||
|
|||||||
Re: Issue in calling an ajax request in admin area.
Hello, ajeetsingh
You should define the list of actions not secured by formid checking in your NotifTmplts controller to overcome this problem: PHP Code:
__________________
Eugene Dementjev XC5 Developer |
|||||||
#6
|
|||||||
|
|||||||
Re: Issue in calling an ajax request in admin area.
Hello Daemos ,
Thank you to help me, Your suggestion is working for me.
__________________
Ajeet Singh Sr.Software Developer Webkul Software Pvt. Ltd. |
|||||||
|
|||
X-Cart forums © 2001-2020
|