Ajax没有得到结果

时间:2017-10-19 13:28:03

标签: ajax

我刚进入ajax,我无法理解代码有什么问题?

的index.html

Rewriterule  ^quiz\/results\/solution-one/([=@.a-zA-Z-]*) /var/www/domain.com/public_html/results.php?level=4&$1 [QSA,L]

ajax.php

<html>
<head>
    <title>Ajax call</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<head>
<body>
    <script>
        var UserID = 'myname';
        var EmailAddress = 'myname@mail.com';

        $.ajax({
            url: "ajax.php",
            type: "get",        //send it through get method
            data: 
                { 
                    ajaxid: 4, 
                    UserID: UserID, 
                    EmailAddress: EmailAddress
                },
            success: function(response) 
                {
                //Do Something
                Alert("Sucess");
                },
            error: function(xhr) 
                {
                //Do Something to handle error
                Alert("Failure");
                }
        });
    </script>
</body>
</html>

解决此问题后,我的主要目标是使用连接到SQL Server的函数替换php文件中的代码,并使用ajax调用发送的数据检索一些数据。 我稍后会尝试

此致 埃利奥·费尔南德斯

1 个答案:

答案 0 :(得分:0)

Alert("smth")更改为alert("smth") 然后在success函数中,您需要&#34;发送&#34;服务器对html的响应

success:function(response){
    alert('success')
    $('body').append(response)
}