jQuery-Ajax显示空的RESPONSE/Success:与WordPress帖子和页面一起使用时不触发



如有任何帮助,我们将不胜感激。

我创建了一个小脚本,当与简单的php页面一起使用时,它可以很好地工作。现在我只是尝试将这个脚本添加到我的WordPress帖子和页面中。所以我使用了"exec.php"插件来调用php脚本。

一切都很好。但是,当用户填写数据并提交表单时,数据实际上会被提交(我可以在firebug中看到发布的变量),但与wordpress一起使用时,响应不会显示在表单下,因为与普通php页面一起使用时效果很好。

我的jQuery代码是这样的:

var dataString = 'name=' + name + '&country=' + country + '&lang=' + language;
$("#paypal-submit").click(function () {
    $.ajax({
        type: "POST",
        url: "get.php",
        data: dataString,
        dataType: 'html',
        success: function (gotresponse) {
            $('#response-id').html("<div id='id-message'><p>Got Response</p></div>");
            $('#id-message').html(gotresponse).fadeIn(1500, function () {
                $('#id-message');
            });
            $('#name').attr('onchange', 'resetForm()');
            $('#country').attr('onchange', 'resetForm()');
        }
    });
});

当我在firebug中实际查看整个过程时,我可以看到数据实际上被发布到了服务器上。

200 OK               2.03s

但当我在firebug控制台中看到响应选项卡时,它是空的。我认为与WordPress一起使用时不会触发成功消息

我想不出是什么问题?有人能帮我解决这个问题吗?

注意:当使用相同的脚本时,它可以正常工作,但当与WordPress一起使用时,不会触发jQuery-Ajax的成功

第一次编辑:

我刚刚包含了错误:在ajax函数中

error:function(x,e){
            if(x.status==0){
            alert('You are offline!!n Please Check Your Network.');
            }else if(x.status==404){
            alert('Requested URL not found.');
            }else if(x.status==500){
            alert('Internel Server Error.');
            }else if(e=='parsererror'){
            alert('Error.nParsing JSON Request failed.');
            }else if(e=='timeout'){
            alert('Request Time out.');
            }else {
            alert('Unknow Error.n'+x.responseText);
            }
        }

现在,当我提交表格时,我会收到一条警报,上面写着"你离线了!!请检查你的网络。"这个错误正在触发。所以现在请帮帮我。

如果您成功:function(),它应该成功:function(data),然后将.html(gotresponse)更改为.html(data)

相关内容

最新更新