当我要使用AJAX提交数据时,IE显示错误,如object doesn't support this property or method
$("#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"});
}
}
});
});
答案 0 :(得分:4)
你不能在JavaScript中'修剪'字符串,因为核心js中没有修剪方法。但是,您可以使用jQuery的trim函数。
$.trim($(this).val())