I am facing a weird issues for the past few days that suddenly all the ajax requests in the site gets redirected to base URL including admin pages.
Ex issue, For auto-complete. Where the response is in json format and i returned true earlier. This got screwed up after the redirection issue starts. I fixed it by exiting in the function instead of returning true. So issue is fixed by some way for custom functionalities.
But i am using CK editor for few fields. Those fields also got screwed up now by showing homepage html instead of original which i fed (when editing back). I identified that there is a ajax redirection happening for CK editor pages also.
What should i do to fix this issue globally ?
it seems that there is a redirect happening maybe in some init hooks. One way to check this is to debug the drupal_goto() function (assuming the redirect is done using it). The easiest is to use a debugger in your IDE and check the entire call stack.
Another way to do this is that in the drupal_goto() function, just before
header('Location: ' . $url, TRUE, $http_response_code);
you put this code:
ob_start();
$backtrace = debug_backtrace();
foreach ($backtrace as $key => $value) {
unset($backtrace[$key]['args']);
}
echo '<pre>'; print_r($backtrace);
$output = ob_get_clean();
watchdog('redirect_debug', 'Redirect to url: ' . $url. ' from ' . request_uri() . '. Call stack: ' . $output, NULL);
Then, run the ajax request and just go and inspect your watchdog entries. In case the redirect is done by drupal_goto() you will see all the call stack, so you can see from which line is done.
How to actually fix it, it really depends on where there redirect is done from.