在Safari中使用应用程序时出现“Assertion failed: (anonymous function)”错误

6

我正在使用Java、JavaScript、HTML和Rest创建一个iPad应用程序。我有一个国家列表,想在应用程序的某个页面中显示为下拉列表。我尝试使用rest来填充此列表,但是当我运行应用程序时,下拉列表中没有任何内容,并且Safari报错。

Assertion failed: (anonymous function) :449

我遇到了这个错误,出现了8次,每次数字不同。

这是我正在使用的一些代码:

main.html

<div id="wrapper">
<div id="mainBackground">
     <div id="stflogo"><img src="images/logo.png" width="200" height="186" alt="MyLogo logo" /></div>

<div id="formContainer">
        <h1>Register Your Card</h1>
        <form id="AccountDetailsForm" method="post" data-ajax="false">

                <input  id="tfscCardNumber" type="hidden" name="tfscCardNumber" class="readonly" minlength="2" maxlength="20" readonly="readonly" disabled="disabled"/>


                <p><label id="firstNameLabel" for="firstName" class="displayBlockLabel RequiredField">First Name </label>
                <input id="firstName" type="text" name="firstName" class="required" minlength="2" maxlength="20"/></p>
                <p><label id="lastNameLabel" for="lastName" class="displayBlockLabel RequiredField"> Last Name </label>
                <input id="lastName" type="text" name="lastName" class="required" minlength="2" maxlength="25"/></p>        

                <p><label id="address1Label" for="address1" class="displayBlockLabel RequiredField">Address 1 </label>
                <input id="address1" type="text" name="address1" class="required" minlength="2" maxlength="40"/></p>
                <p><label id="address2Label" for="address2" class="displayBlockLabel">Address 2</label>
                <input id="address2" type="text" name="address2" maxlength="40"/></p>

                <p><label id="cityLabel" for="city" class="displayBlockLabel RequiredField">Town / City </label>
                <input id="city" type="text" name="city" class="required" minlength="2" maxlength="40"/></p>

               <p> <label id="countyLabel" for="county" class="displayBlockLabel RequiredField">County / State </label>
                <input id="county" type="text" name="county" class="required" minlength="2" maxlength="40"/>    </p>

               <p> <label id="postcodeLabel" for="postcode" class="displayBlockLabel RequiredField">Postcode / Zip </label>
                <input id="postcode" type="text" name="postcode" class="required" minlength="2" maxlength="11"/>    </p>                

               <p> <label id="countrySelectionLabel" for="countrySelection" class="displayBlockLabel RequiredField">Country </label>
                <select id="countrySelection" class="required">
                </select> </p>

               <p><label id="telephoneLabel" for="telephone" class="displayBlockLabel RequiredField">Tel Number </label>
                <input id="telephone" type="tel" name="telephone" class="tel number required" minlength="2" maxlength="12"/></p>    
                <p><label id="emailLabel" for="email" class="displayBlockLabel RequiredField">Email </label>
                <input id="email" type="email" name="email" class="email required" minlength="2" maxlength="100"/></p>                                      
                <p><label id="confirmEmailLabel" for="confirmEmail" class="displayBlockLabel RequiredField">Confirm Email </label>
                <input id="confirmEmail" type="email" name="confirmEmail" class="email required" minlength="5" maxlength="100"/></p>    

                <p><label id="passportNumberLabel" for="passportNumber" class="displayBlockLabel RequiredField">Passport Number </label>
                <input id="passportNumber" type="text" name="passportNumber" class="required" minlength="3" maxlength="20"/></p>        
                <p class="tandcnotice">Please Ensure that you have read the Terms &amp; Conditions and Privacy &amp; security Policy</p>

                <p class="tandcCheckbox">
                <input type="checkbox" name="accepttandc" id="accepttandc" class="checkbox" />
                <label for="checkbox" class="accepttandc">I have read the Terms &amp; Conditions</label>
                <p>

                <input class="button" type="submit" value="Submit" data-role="button" data-theme="redbutton"/>
        </form>
     </div><!-- END OF FORM CONTAINER -->
     </div>
</div>
....

appForm.js

$('#wrapper').live("pageshow", function() {
if ( $('#countrySelection')[0].length < 1){

    $.mobile.loadingMessage = "Retrieving Countries";
    $.mobile.showPageLoadingMsg();

    Repository.load('details/countries/all', function(countries){
        $.each(countries, function() {
            $('#countrySelection').append('<option value="' + this.id + '">' + this.name + '</option>').selectmenu('refresh');
        });
        $.mobile.hidePageLoadingMsg();
    });
}

});


$('#wrapper').live("pagecreate", function() {               

$('#AccountDetailsForm select, #AccountDetailsForm input[type!=submit]').focus(function (){
    focusScroller(this);                                                                                   
});
$('#AccountDetailsForm select, #AccountDetailsForm input[type!=submit]').blur(function (){
    if ( $('#accountFormScrollView').data().scrolllistview._sy < $('#accountFormScrollView').data().scrolllistview._maxY){
         $('#accountFormScrollView').data().scrolllistview.scrollTo(0, $('#accountFormScrollView').data().scrolllistview._maxY, 0);
    }
}); 

});           


$(window).resize(function (){
// Android Resize Event needed for the keyboard
});

var focusScroller = function(formElement){
    $(window).scrollTop(0);
    var elementLabel = "#" + formElement.id + "Label";   
    var offSetPosition = $(elementLabel)[0].offsetTop;
    if(formElement.labels === undefined && formElement.id === "countrySelection"){
        // ios4 quirk for select elements
        offSetPosition = 100; 
    }

    scrollTo(0,0,0);
    $('#accountFormScrollView').data().scrolllistview.scrollTo(0, offSetPosition * -1, 0);
}


$('#wrapper"').live("pageshow", function() {
if (getTfscCardNumber() === ''){
    $('#passportNumberLabel').css('display', 'none');
    $('#passportNumber').css('display', 'none'); 
    $('#passportNumber').attr("disabled", true);
}else{
    $('#passportNumberLabel').css('display', 'block');
    $('#passportNumber').css('display', 'block'); 
    $('#passportNumber').attr("disabled", false);
}

loadForm($('#AccountDetailsForm')[0]);
});

我可以提供更多的代码,如果需要的话,但我确信其余的代码是没有问题的,如果有任何人想查看任何其他代码片段,请询问。
这个错误是什么意思?有人能看出哪里出了问题吗?

我认为它意味着你在第449行有一个错误。 - hugomg
我不这么认为,因为我的任何一个类中都没有449行代码,所以那肯定是不正确的。 - newSpringer
1
这可能是由你正在使用的库引起的。如果你能在桌面上运行它,你可以使用浏览器内置的调试工具获取更多信息,但在iPad上我认为这些工具不可用... - hugomg
我目前正在我的桌面上运行,并使用Firefox和Safari进行测试。 - newSpringer
尝试在Chrome Inspector中运行此代码,单击“脚本”选项卡并点击左下角的停止标志,直到它变为紫色-这将在异常抛出时停止,您可以查看调用堆栈。由于这是在自执行函数中发生的,因此除非在捕获异常时进行调试,否则很难确定具体位置。 - acconrad
1个回答

10

谢谢 :) 我一直忽略它,因为它没有影响我的应用程序,但这仍然让我感到烦恼,不知道为什么会发生这种情况。 - newSpringer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接