Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将.ajax添加到我的jquery会导致页面加载挂起_Php_Jquery_Ajax_Load - Fatal编程技术网

Php 将.ajax添加到我的jquery会导致页面加载挂起

Php 将.ajax添加到我的jquery会导致页面加载挂起,php,jquery,ajax,load,Php,Jquery,Ajax,Load,我有一个使用引导和jquery的页面。基本上会显示一个会议与会者表,并允许主持人进行登记。如果未注册(即未在DB中注册),主机还可以添加新的与会者 我有一个现有的工作按钮,名为attent,它有一个onclick事件,并调用一个php函数来更新数据库。这项工作: <script> // This is the function that is called when the Arrive button is clicked $(function() { $(

我有一个使用引导和jquery的页面。基本上会显示一个会议与会者表,并允许主持人进行登记。如果未注册(即未在DB中注册),主机还可以添加新的与会者

我有一个现有的工作按钮,名为attent,它有一个onclick事件,并调用一个php函数来更新数据库。这项工作:

<script>
// This is the function that is called when the Arrive button is clicked
$(function() 
    {
        $('button#attendedButton').on('click', function (e) {
            var idFromRow = $(this).data('id');
            // Change the color of the button
            $(this).css('background-color', '#428bca')
            // Disable the button
            $(this).prop('disabled', true)
            // Change the button text
            $(this).text('Arrived')
            // Change the cell next this button and mark it as Atten
            $(this).closest('td').prev().text('Attended')
            idFromRow = idFromRow + '&action=setAttended'

            // for testing we can alert the variables 
            //alert(idFromRow)
            // Call the php function to update the database

            $.ajax({type: "GET", url:"CheckInFunctions.php", data: idFromRow})
            })
    }
)
</script>

//这是单击到达按钮时调用的函数
$(函数()
{
$('button#attendedButton')。在('click',函数(e)上{
var idFromRow=$(this).data('id');
//更改按钮的颜色
$(this.css('background-color','#428bca'))
//禁用按钮
$(this.prop('disabled',true)
//更改按钮文本
$(this.text('arrized'))
//更改此按钮旁边的单元格并将其标记为Atten
$(this).closest('td').prev().text('Attended'))
idFromRow=idFromRow+“&action=SetAttentied”
//对于测试,我们可以警告变量
//警报(idFromRow)
//调用php函数来更新数据库
$.ajax({type:“GET”,url:“CheckInFunctions.php”,数据:idFromRow})
})
}
)
现在,我添加了一个模式弹出窗口,要求提供联系信息,然后单击该按钮即可实现此功能

<script>
// This is the function that is called when the Add button is clicked
$(function() 
    {
        $('button#addAttendeeSubmit').on('click', function (e) {

            fname = document.getElementById ("newAttendeefname").value
            lname = document.getElementById ("newAttendeelname").value
            email = document.getElementById ("newAttendeeemail").value
            note = document.getElementById ("newAttendeeNote").value
            phone = '111-555-1212'
            //phone = document.getElementById ("newAttendeefname").value

            newInfo = 'fname='+fname+'&lname='+lname+'&email='+email+'&phone='+phone+'&note='+note+'&action=addAttendee'
            // for testing we can alert the variables 
            alert(newInfo)
            // console.log('here we are in add submit')
            // Call the php function to update the database
            //$.ajax({type: "GET", url:"CheckInFunctions.php", data: newInfo})
            })
    }
)
</script>

//这是单击“添加”按钮时调用的函数
$(函数()
{
$('button#AddAttendee Submit')。在('click',函数(e)上{
fname=document.getElementById(“newAttendeefname”).value
lname=document.getElementById(“NewAttendeeName”).value
email=document.getElementById(“newAttendeeMail”).value
note=document.getElementById(“NewAttendeNote”).value
电话='111-555-1212'
//phone=document.getElementById(“newAttendeefname”).value
newInfo='fname='+fname+'&lname='+lname+'&email='+email+'&phone='+phone+'¬e='+note+'&action=addAttendee'
//对于测试,我们可以警告变量
警报(新信息)
//log('这里是添加提交')
//调用php函数来更新数据库
//$.ajax({type:“GET”,url:“CheckInFunctions.php”,data:newInfo})
})
}
)
奇怪的是,现在当我加载页面(甚至在出现任何弹出窗口之前)时,页面加载会挂起-如果我对页面加载的.ajax调用(正如摘录中所述)进行注释,我可以获得模式弹出窗口,填写信息并查看警报


我打破了什么?

答案是,我与ajax对话的实际服务器间歇性停机,因此产生了奇怪的结果。有时ajax调用会成功,有时会挂起或失败。

您是否尝试使用firebug(或类似的开发工具)检查GET请求是否已发送,如果已发送,返回什么?