AJAX Call 404'ing on staging server

时间:2015-11-12 12:09:10

标签: php jquery ajax wordpress

I have AJAX form submission working fine locally. But when pushed to my staging server the process page is 404'ing. I cannot access it directly neither as it 404's but checking on the server and its 100% there with correct permissions too.

The code for the AJAX:

$('body').on('submit', '.product-form', function(e){
    e.preventDefault();
    $.ajax({
        url : '/wp-content/themes/hinge_client_theme/page-templates/template-parts/template-logic/send-form.php',
        type : 'POST',
        data : thisForm.serialize(),
        before : $(".error-message").remove(),
        success : function(data) {        
            // removed for question
        },
    });
});

That send-form.php is 404ing on the network tab, any ideas whats going on? Working fine locally.

This a WordPress site but not sure if that is whats affecting it since it works locally.

The URL its trying to call on staging is:

http://staging.domain.com/wp-content/themes/my-theme/page-templates/template-parts/template-logic/send-form.php 

1 个答案:

答案 0 :(得分:0)

您必须使用此类网址进行暂存

    url : '/staging/wp-content/themes/hinge_client_theme/page-templates/template-parts/template-logic/send-form.php',

因为你在文件夹“staging”。