Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: check if called via ajax before including jQuery (custom url param)
- Loading branch information
LouisGac
committed
Jul 27, 2016
1 parent
cf0c793
commit a10bd8b
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a10bd8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extend https://github.com/LimeSurvey/LimeSurvey/blob/master/framework/web/CHttpRequest.php#L677 is better. Because , actually : cqgrid with $_GET seems to return whole html
a10bd8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And : maybe it's better to leave whole system, and only fix render function (via extend)
https://github.com/LimeSurvey/LimeSurvey/blob/master/framework/web/CClientScript.php#L203
Here : only include script and meta if needed.
But : did this not linked with layout ? What is the layout actually ?
a10bd8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups, sorry again.
We don't have to extend Yii, because Yii is not used actually ....
We must fix : https://github.com/LimeSurvey/LimeSurvey/blob/master/application/core/Survey_Common_Action.php#L241
And add header/footer only if we are not in ajax (using
$_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'
? )a10bd8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Denis,
Basically, the Yii method : Yii::app()->request->isAjaxRequest is doing what you say (testing the headers). Problem is that headers depend highly on server configuration, and can retrieves unexpected results. The problem is well known, and adding a param in the ajax request seems to be the most used solution:
http://www.yiiframework.com/wiki/251/reliable-alternative-for-yii-app-request-isajaxrequest-and-adding-data-to-ajax-form-with-js/
I also like the idea of extending the render function.
a10bd8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK :) seems CGgrid add ajax to GET parameters : then :
isAjaxRequest =($_REQUEST['ajax'] || $_REQUEST['isAjax'] || $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'])
Making a grep on framework seems to show test on $_POST['ajax'] only.