• Coding
  • Wordpress, custom permalinks and XMLHttpRequest Help

I updated Wordpress on my website the other day and I was met with difficulties with custom permalinks and XMLHttpRequest (yes I'm not using Jquery's .load() Ajax function).

So after several google searches, it turned out that everyone was having this problem and I couldn't find an appropriate solution.

Problem:

I initiated a XMLHttpRequest object named xmlhttp.
Now this next line used to work before I updated Wordpress:
xmlhttp.open("GET","http://www.mywebsite.com/etc/etc/myPhpFile.php?q=" +str, true);
where the "str" value gets sent from a click event on a label - so imagine I click a label named myLabel so I get str = myLabel in this example.

This was working perfectly before I updated Wordpress and the catch is that it was working with custom permalinks.

Now if I set custom permalinks, I get a 404 Not Found on http://www.mywebsite.com/etc/etc/myPhpFile.php?q=myLabel

Alternatively, if I change Wordpress's Permalinks to Default, everything works fine again and I get Ajax results from myPhpFile.

So the problem is basically that setting custom permalinks in my updated version of Wordpress is causing the url in my XMLHttpRequest.open object to be 404 Not Found!

P.S: I really need to stick to my old custom permalinks and not revert to the default one for my Ajax calls to work.
Which version of wordpress did you have and which one did you update to? If its from WP2.x to 3.x Try requiring wp-load.php instead of wp-blog-header.php in your loader template file. Hope that helps.
Info: I upgraded from 2.7 to 3.1.1 (still hesitant to upgrade to 3.3).

Ayman, you're a life saver. I spent the whole day googling to no avail. Nobody ever mentioned anything about including wp-load instead of wp-blog-header in the loaded template file!

It worked perfectly, thank you for your help!
Your welcome glad that it helped! :)