iPad 上的 JavaScript 问题
我们在网页上有一些非常非常基本的 JavaScript,并且在每个浏览器上都可以正常工作。用 Firebug 检查过,没有问题、错误或任何东西。
但是当我们在 iPad 上运行它时(假设这也会影响其他移动设备),这个 JS 就会被忽略。
应该准备好文档还是加载文档?
$(document).ready(function()
{
$("#myshopname").blur(function()
{
$("#msgbox").removeClass().addClass('messagebox').html('<img class="check" src="images/loader.gif"> Checking...').fadeIn("slow");
$.post("user_availability.php",{ user_name:$(this).val() } ,function(data)
{
if(data=='no')
{
$("#msgbox").fadeTo(200,0.1,function()
{
$(this).html('oh bugger, this Shop is reserved').addClass('messageboxerror').fadeTo(900,1);
});
}
else
{
$("#msgbox").fadeTo(200,0.1,function()
{
$(this).html('woohoo this Shop is available').addClass('messageboxok').fadeTo(900,1);
});
}
});
});
});
实际上JS似乎可以工作,它只是没有启动PHP(通过JS调用)
js应该引用的php是:
<?php
$existing_users=array('apple','orange','pear','nectarine','fartbag');
$user_name=$_POST['user_name'];
if (in_array($user_name, $existing_users))
{
echo "no";
}
else
{
echo "yes";
}
?>
显然,我们会将其连接到数据库并在实时站点上以不同的方式运行,但需要使其在所有浏览器和设备上的客户端上工作。
We have some very very basic JavaScript, on a webpage and works fine on every browser. Checked with Firebug, no issues, errors or anything.
But when we run it on an iPad ( presuming this affects other mobile devices, too ) this JS is being ignored.
Should it be doc ready or doc load?
$(document).ready(function()
{
$("#myshopname").blur(function()
{
$("#msgbox").removeClass().addClass('messagebox').html('<img class="check" src="images/loader.gif"> Checking...').fadeIn("slow");
$.post("user_availability.php",{ user_name:$(this).val() } ,function(data)
{
if(data=='no')
{
$("#msgbox").fadeTo(200,0.1,function()
{
$(this).html('oh bugger, this Shop is reserved').addClass('messageboxerror').fadeTo(900,1);
});
}
else
{
$("#msgbox").fadeTo(200,0.1,function()
{
$(this).html('woohoo this Shop is available').addClass('messageboxok').fadeTo(900,1);
});
}
});
});
});
Actually the JS seems to work, it just doesnt initiate the PHP ( called via JS )
The php that the js should reference is:
<?php
$existing_users=array('apple','orange','pear','nectarine','fartbag');
$user_name=$_POST['user_name'];
if (in_array($user_name, $existing_users))
{
echo "no";
}
else
{
echo "yes";
}
?>
We will obviously connect this to db and run differently on live site, but need to get this to work clientside on all browsers and devices.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论