iPad 上的 JavaScript 问题

发布于 2025-01-04 03:48:04 字数 1399 浏览 1 评论 0原文

我们在网页上有一些非常非常基本的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文