2013-07-07 67 views
0

我是Jquery和Parse的新手,我不會說英文,所以首先對於問題的語法感到抱歉。 我寫了一個函數,更新parse.com上的Artist對象(updateArtist(objectId))。當我點擊保存按鈕時,這個函數被調用,並在FireFox和Chrome上正常工作,但在Safari上不能正常工作。Jquery和JavaScript SDK解析Safari的問題

function updateArtist(objectId) { 

    Parse.initialize("myid", "myid"); 


    alert(objectId); 

    var Artist = Parse.Object.extend("Artist"); 
    var query = new Parse.Query(Artist); 

    query.equalTo("objectId", objectId); 

    query.first({ 
    success: function(object) { 
     // Successfully retrieved the object. 
     $('#createArtist').css('visibility', 'hidden'); 
     $('.loadingImage').css('visibility', 'visible'); 

     alert('success'); 

     var name = $("#txtName").val(); 
     var link = $("#txtLink").val(); 
     var desc = $("#txtDesc").val(); 
     var place = $("#txtPlace").val(); 
     var latitude = parseFloat($("#txtLat").val()); 
     var longitude = parseFloat($("#txtLong").val()); 
     var eventDate = $('#txtDate').val(); 
     var eventTime = $('#txtTime').val(); 

     console.log(eventDate); 
     console.log(eventTime); 
     console.log(name); 
     console.log(link); 
     console.log(place); 
     console.log(desc); 
     console.log(latitude); 
     console.log(longitude); 

     if (eventDate.charAt(2)=='/') { 

      var dateArray = eventDate.split('/'); 

      var month = dateArray[0] - 1; 
      var day = dateArray[1]; 
      var year = dateArray[2]; 

     } else if (eventDate.charAt(2)=='-') { 

      var dateArray = eventDate.split('-'); 

      var month = dateArray[1] - 1; 
      var day = dateArray[0]; 
      var year = dateArray[2]; 

     } 

     console.log(month); 
     console.log(day); 
     console.log(year); 
     var timeArray = eventTime.split(':'); 
     var finalDate = new Date(year, month, day, timeArray[0], timeArray[1], 0, 0); 

     console.log(timeArray); 
     console.log(finalDate); 


     var point = new Parse.GeoPoint(latitude, longitude); 

     console.log(point); 


     var fileUploadControl = $("#profilePhotoFileUpload")[0]; 

     if (fileUploadControl.files.length > 0) { 
     var file = fileUploadControl.files[0]; 
     var photoName = "photo.jpg"; 

     var parseFile = new Parse.File(photoName, file); 
     } 

     parseFile.save().then(function(){ 

     object.save(null, { 
      success: function (contact) { 


      alert('secondo success'); 

      contact.set("name", name); 
      contact.set("link", link); 
      contact.set("description", desc); 
      contact.set("place", place); 
      contact.set("geoLocation", point); 
      contact.set("eventDate", finalDate); 

      contact.set("image", parseFile); 

      contact.save(); 
      window.location.href = "artist_list.html"; 
      } 
     }); 

     }); 



    }, 
    error: function(error) { 
     alert("Error: " + error.code + " " + error.message); 
    } 


    }); 


} 

我使用Safari 6.0.5和警報和執行console.log給我我想要什麼,我完全失去了..

回答

0

當你調用「updateArtist」?請確保您等待$(document).ready(function(){...})。