1

我正在使用 phonegap android,其中我使用 sqlite 数据库来存储数据。我的程序运行完美,但我的 ajax 加载程序没有卡明请帮助我解决我在程序中犯的错误,即我的 ajax 加载程序没有卡明

在jQuery中: -

     function get_Emp_List() {             
       $("#employee").empty();

       $(location).attr('href', '#emp1');
       $.support.cors = true;   
       $.ajax({
            type: "GET",
            url: "one.html",
            contentType: "text/xml",
            dataType: "xml",
            data: "",
             beforeSend:function () { 
                 $.mobile.loading('show',{
                  text: "Loading...",
                   textVisible: true,
             theme: "d",
             textonly: false,
             html: ""
          });
          },
          complete:function () {     
              $.mobile.loading('hide');
          },
        crossDomain:true,
            success: function (data) {                  
                      $(data).find("employee").each(function () {   

                      var emp_id = $(this).find('id').text();
                      var emp_name = $(this).find('short_name').text();


                       db.transaction(function(transaction) {
                             transaction.executeSql('INSERT INTO Envy_Emp VALUES((SELECT max(_idEE)+1 FROM Envy_Emp),"'+emp_id+'","'+emp_name+'")',nullHandler,errorHandler);
                        });
                         });                     
                 ids_Dynamic_Emp_List();

                      return false;
                   },
            error: function (data) {
                    alert("error");
            }
        });     
    }

      /*  end Employee list script */

    /*ids_Dynamic_Emp_List() method coding Start*/ 

       function ids_Dynamic_Emp_List(){
           /*sql start*/

        /*sqlite code for dynamic Emp list*/
      db.transaction(function(tx){
        tx.executeSql('SELECT * FROM Envy_Emp;', [], 

    function(tx,results){

               if (results != null && results.rows != null) { 
                var myLen=results.rows.length;
                 for (var i = 0; i < results.rows.length; i++) {
                     var for_Name = results.rows.item(i).Envy_Emp_Name;
                     var for_ID = results.rows.item(i).Envy_Emp_ID;
                     var for_E_ID=results.rows.item(i)._idEE;
                    /*create table list Dynamically using Sqlitedata base */
                         var scripts = "<a href='#' data-role='button' data-theme='b' data-inline='true' onclick='get_Menu_List(id);' id='"+for_E_ID+"'>"+for_Name+"</a>";
                         alert(scripts);
                      $(".employee1")
                      .append(scripts)
                      .trigger('create');
                    /*create table list Dynamically using Sqlitedata base End*/ 
                    }
                  }
               },errorHandler);
              }
             ,errorHandler,nullHandler);
             return; 
              }
4

0 回答 0