jqueryajax中的返回值

jqueryajax中的返回值,ajax,jquery,Ajax,Jquery,我正在研究jQueryAjax。我使用的代码如下: var url = baseurl +"/index.php/users/ajaxwixusers"; var dataStringfirst = 'wixuserid='+ instanceId; $.ajax({ //dataType : 'html', type: 'GET', url : url, data : dataStr

我正在研究jQueryAjax。我使用的代码如下:

var url = baseurl +"/index.php/users/ajaxwixusers";
    var dataStringfirst = 'wixuserid='+ instanceId;
    $.ajax({
            //dataType : 'html',
            type: 'GET',
            url : url,
            data : dataStringfirst,
            complete : function() { },
            success: function(data) 
                    {
                        alert(data);
                        window.location.href="http://localhost:81/customers/index.php/acappointments/appointuseroverlay/user_id/203";
                    }
        });
在PHP文件中,我得到的值为:

echo $user_id = $wixuser->id;
我想回报成功的价值。当我试图提醒ajax的输出时


它将返回文件的完整HTML。我怎样才能只返回值而不是完整的HTML?

它返回完整的HTML,因为你的应用程序一直在运行,并在echo命令后呈现其余的请求。您应该改为添加一行出口

exit();

Ajax响应总是将完整的数据作为请求页面的输出,如果您不想使用HTML,那么为什么要将其放在那里?如果您想获得任何特定值,请仅打印该值,不要在该页面上使用HTML。

当我使用json时,php或ajax中不会返回任何内容。您是否知道您所说的内容,请参阅Telvin的回答谢谢您的建议。