Вопрос

Im using XMLHttpRequest to save something into a database when the user clicks a button. This seems to work when working on localhost, but after I launched the site only a 404-error occurs.

Firefox console says:

POST http://mydomain.com/wp-content/themes/minmeme/save.php [HTTP/1.1 404 Not Found 999ms]

But when I copy that URL and open it manually, the file clearly exists.

Javascript code is saved in script.js and placed in the same folder as save.php:

var ajax = new XMLHttpRequest();
ajax.open("POST",'/wp-content/themes/minmeme/save.php',false);
ajax.setRequestHeader('Content-Type', 'application/upload');
ajax.send(imgurl);
Это было полезно?

Решение

It was the WordPress permalink structure that screwed this up. By using custom permalinks (%postname%) I could not access any .php-file outside of Wordpress directly.

Setting permalinks to standard, now the server finds the file. Error now changed to 403.1 though...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top