I faced the ajax crush issue on views_pdf. Issue is with the latest drupal verion 7.39 and 7.40 so if user upload the pdf file then ajax crushed and show message
CustomMessage: The response failed verification so will not be processed.
Views_pdf using Views module api so I found the following details:
Views is passing wrong url to ajax which does not match the Drupal.settings.urlIsAjaxTrusted e,g
Views ajax.url: http://drupal740.local/admin/structure/views/ajax/display/views_pdf/pdf_...
Drupal.settings.urlIsAjaxTrusted : {"/admin/structure/views/view/views_pdf/edit/pdf_1?render=overlay":true,"/admin/structure/views/view/views_pdf/preview/pdf_1/ajax":true,"/admin/structure/views/view/views_pdf/preview/pdf_1":true,"/admin/structure/views/ajax/display/views_pdf/pdf_1/pdf_template":true}
In the above scenario Drupal ajax does not pass it and crush the response
/misc/ajax.js line number 183
if (response !== null && !Drupal.settings.urlIsAjaxTrusted[ajax.url]) {
if (xmlhttprequest.getResponseHeader('X-Drupal-Ajax-Token') !== '1') {
var customMessage = Drupal.t("The response failed verification so will not be processed.");
return ajax.error(xmlhttprequest, ajax.url, customMessage);
}
}
We can resolve this by changing this line of code
Current views/includes/ajax.inc line number 268:
$url = empty($form_state['url']) ? url($_GET['q'], array('absolute' => TRUE)) : $form_state['url'];
Should be:
$url = empty($form_state['url']) ? request_uri() : $form_state['url'];
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | views-2595607-ajax-wrong-url.patch | 483 bytes | asghar |
Comments
Comment #2
asghar commentedComment #3
asghar commentedComment #4
kala4ekComment #5
vegansupreme commentedThis patch solves the problem in Views PDF for me. I wonder if there are other Views related modules having a similar problem?
Comment #6
asghar commentedIf other modules are using the file field attachment in settings as views_pdf then they will definitely face the same issue.
Comment #7
vegansupreme commentedI vote for this solution. Any idea why the test isn't working?
Comment #8
steven jones commentedI'm not 100% sure it's the same issue, but I think it might be: #2572117: Unable to change settings in views after Drupal upgrade which, has a different patch, that might also fix this issue.
Comment #9
troybthompson commentedThis solved my problem with views_pdf
Comment #10
chris matthews commentedThe 3 year old patch in #3 to ajax.inc applied cleanly to the latest views 7.x-3.x-dev and appears to be ready to RTBC.