Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.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
javascript条件if语句中的错误_Javascript_If Statement_Conditional - Fatal编程技术网

javascript条件if语句中的错误

javascript条件if语句中的错误,javascript,if-statement,conditional,Javascript,If Statement,Conditional,将PHP项目上传到互联网主机(000webhost.com)后,我得到了一份保险。它在我的本地主机上运行良好,但在internet主机上不起作用。这是我的密码: //view.php (use a hidden iframe to received data after submitting) <form action="model.php" method="POST" target="my_iframe" id="my_form" style="display: none;">

将PHP项目上传到互联网主机(000webhost.com)后,我得到了一份保险。它在我的本地主机上运行良好,但在internet主机上不起作用。这是我的密码:

//view.php (use a hidden iframe to received data after submitting)
<form action="model.php" method="POST"  target="my_iframe" id="my_form" style="display: none;">
                <input type="hidden" name="user" id="user" value=""/>
                <input type="hidden" name="user_lastname" id="user_lastname" value=""/>
                <input type="hidden" name="user_firstname" id="user_lastname" value=""/>
            </form>
<iframe name="my_iframe" id="my_iframe" style="display: none;"></iframe>
<div id="sent">Sent</div>
<srcipt type="text/javascript">
    jQuery('#sent').unbind('click').click(funtion(){
        jQuery('#user').val("an user name");
        jQuery('#user_lastname').val("a last name");
        jQuery('#user_firstname').val("a first name");
        jQuery('#my_form').submit();
        jQuery('#my_iframe').unbind('load').load(function(){
            if(jQuery(this).contents().text()!='success')
               alert('Update failed');
            else
               alert('Update successful');
        });
     });

</script>

//model.php
if(UpdateUser($_REQUEST['user'],$_REQUEST['user_firstname']),$_REQUEST['user_lastname'])==true)
   echo 'success';
else
   echo 'Fail in updating';
//view.php(提交后使用隐藏的iframe接收数据)
发送
jQuery('#sent')。解除绑定('click')。单击(函数(){
jQuery('#user').val(“用户名”);
jQuery('#user_lastname').val(“姓氏”);
jQuery('#user_firstname').val(“名字”);
jQuery(“#我的表单”).submit();
jQuery(“#我的iframe”).unbind('load').load(函数(){
if(jQuery(this).contents().text()!='success')
警报(“更新失败”);
其他的
警报(“更新成功”);
});
});
//model.php
if(UpdateUser($\u REQUEST['user'],$\u REQUEST['user\u firstname']),$\u REQUEST['user\u lastname'])==true)
呼应"成功",;
其他的
echo“更新失败”;
在我的本地主机上,我收到一条消息“更新成功”,但在我的internet主机上,我收到一条消息“更新失败”。谢谢你的帮助。对不起,因为我的英语不好

---编辑----
我更改iframe的style=“display:block”以显示其内容。我看到iframe的内容是“success”,但我仍然收到消息“Update failed”。这意味着:

我更正了拼写错误(还有另一个:脚本第一行的函数拼写为“funtion”)。
jQuery脚本正在工作,因此问题一定出在PHP页面上。可能WebHost在PHP页面的输出之前放置了一些输出,或者更新失败。检查PHP页面的输出。

您在
中拼错了“script”。但是我假设它在真正的脚本中是正确的,否则什么都不会运行。您是否检查了Web服务器日志以查看model.php是否正在运行?
UpdateUser
正在更新它应该更新的内容吗?UpdateUser工作正常。数据库已正确更新。如何检查web服务器日志?如果数据库已更新,则脚本显然已运行。如果您使用Firebug或开发人员工具检查iframe,是否会看到iframe更新“成功”?为什么要使用隐藏的iframe而不是AJAX?您的整个机制似乎非常脆弱,iFrame已被弃用。哦,因为在我的项目中,我使用了大量输入type=“checkbox”从用户那里获取选择。这是一个英语测试项目。它的代码太长了,所以我在这里只展示了一个相同的例子,谢谢你检查我的拼写错误。但是我不明白“检查php页面”的意思。我确信我的UpdateUser函数工作正常。我的意思是,即使UpdateUser函数工作正常,服务器也有可能输出除“成功”之外的其他内容。由于使用了$\u请求,所以可以直接调用model.php并将参数作为get值(model.php?user=abc)放置。通过这种方式,您可以检查model.php输出是否正确(应仅为“success”-7个字符,不再多),非常感谢。我通过对从iframe获得的字符串使用trim()解决了我的问题。