Jump to content

$config->ajax not being set


Mackski
 Share

Recommended Posts

$config->ajax is being set locally, however the exact same call for my client it is not.

The request for my client is rather long, 25 seconds. However, I'm stumped as to why, this should not affect this code:

$config->ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');

If I remove the if($config->ajax) from my ajax function, everything works as expected.

Headers sent look correct:

Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:wire=vg8bth2bcv2c8gq58nbbfean61; wire_challenge=nVbLGO0aHzCu%2FMO9ekc4t.N6ol.xf8s5
Host:**
Referer:http://***
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
X-Requested-With:XMLHttpRequest

 

Link to comment
Share on other sites

Do I understand this correctly, that the client does test the site on a different server than you local one? The question is not only if headers are correctly sent, but also if those headers make it to the server. Some hosters have crazy setups with nginx or even varnish in front of the actual webserver, so things could easily get lost on the way.

Link to comment
Share on other sites

The client is actually accessing my local server. I've tested with some other clients who don't see this issue. Strangly it's only happening in one page.

 

My Ajax call is sent to a different URL within the project. The same call is also being used elsewhere without issue. 

Link to comment
Share on other sites

21 hours ago, Mackski said:

$config->ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');

I'm probably missing something, but not sure why you are overriding $config->ajax here. This variable is set for you by PW when the current request is AJAX - you shouldn't have to set this yourself.

Link to comment
Share on other sites

25 minutes ago, Robin S said:

I'm probably missing something, but not sure why you are overriding $config->ajax here. This variable is set for you by PW when the current request is AJAX - you shouldn't have to set this yourself.

No, I was just showing the line of code which appears to not work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...