开发者

jQuery form - PHP script "not found" but message is being sent successfully

I'm using jQuery Form plugin to create a very simple contact form. However, there seems to be some conflict (?) between it and the PHP script I'm using as well.

The call is super simple, like so:

$('.contactform').ajaxForm({
    target: '#error',
    beforeSubmit: function() { 
        $('#error span').remove();
        $('#error').append('<p class="loading">Sending your message...</p>');
    },
    success: function() {
        $('#error p.loading').fadeOut();
        $('#error').fadeIn('slow');
    }
});

it takes the POST method from the form by default. What happens is, the script is stuck on "sending your message", even though the PHP script is successful, gives a response and sends the message correctly. I checked in Firebug, and it seems like there's an 404 error for the PHP script, but the response is correct (see the image)

jQuery form - PHP script "not found" but message is being sent successfully

开发者_运维百科

I would love some help debugging the problem - the PHP script that's supposedly cannot be found can be viewed here: http://pastie.org/1350597

I have no idea what could cause such a weird behavior. Thanks in advance!


I'd say that wordpress is setting the the 404 (not found) header somewhere in this line:

include "../../../../wp-blog-header.php"

The actual php functions correctly, but wordpress is expecting a URL to a blog post. Instead of using include, you can use require:

require "../../../../wp-blog-header.php"

Depending on the version of wordpress, you may have to also force the header to a 200 OK:

status_header(200);
nocache_headers();

Some more examples are here:

http://wordpress.org/support/topic/integrating-wp-in-external-php-pages

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜