2013-02-12 88 views
2

當我打算提交使用AJAX數據時IE顯示錯誤,如object doesn't support this property or methodIE顯示錯誤 - 對象不支持此屬性或方法

$("#savebasicInfo").live("click",function() 
    { 

    var lookingfor=''; 
    var interestedIn=''; 
    $(".lookingfor").each(function(i) 
    { 
     if(this.checked == true) 
     { 
     lookingfor= lookingfor+","+$(this).val().trim(); // error found here 
     } 
     i++; 
    }); 
    $(".interestedIn").each(function(j) 
    { 
     if(this.checked == true) 
     { 
     interestedIn= interestedIn+","+$(this).val().trim(); // error found here 
     } 
     j++; 
    }); 
    $.ajax(
    { 

     type: "POST", 
     url: $("#cfgRoot").val()+'/accounts/basicInfoPost.php', 
     data: 
     { 
     city:$("#city").val().trim(), 
     hometown:$("#hometown").val().trim(), 
     interestedIn:interestedIn, 
     relationship:$("#relationship").val().trim(), 
     lookingfor:lookingfor, 
     political:$("#political").val().trim(), 
     religious:$("#religious").val().trim() 
     }, 
     success: function(responce) 
     { 
     if(responce == 1) 
     { 
      $("#basicProfileMain").load("basicInfoMain.php"); 
      $("#basicProfileMain").css({"height":"auto"}); 

     } 
     } 
    }); 
    }); 
+1

IE不支持修剪看到這個問題http://stackoverflow.com/questions/2308134/trim-in-javascript-not-working-in-ie – 2013-02-12 06:56:04

回答

4

你不能「修剪」在JavaScript字符串作爲這樣的因爲核心js中沒有修剪方法。不過,你可以使用jQuery的trim功能。

$.trim($(this).val()) 
+0

感謝您的幫助 – 2013-02-12 07:05:02

+0

歡迎您@SumitBijvani – darshanags 2013-02-12 11:10:24

相關問題