This is an example of ajax post request. It work when placed outside of wordpress active theme directory. However when it is there and norefresh.php is also uploaded there it doesn’t work no matter what exact patch to norefresh.php I use (site/themefolder/norefresh.php or server patch or local patch norefresh.php or /norefresh.php). Doesn’t work at all.
Is there anything about wordpress that prevents the execution.What should I do?
$.ajax({
type: "POST",
url: "norefresh.php",
data: reqdata,
cache: false,
success: function(html) {
//document.getElementById('myTextarea').value = html;
alert(html);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
You can allow access using htaccess to the specific file, but this will be a pain for your clients / if you move sites etc?
Better just to hook the function either from your plugin or theme. Then you don’t need to worry about relative uris. (some minor differences in the js but other than that virtually the same)
JS