我无法在JavaScript this.value
中使用单引号。双引号工作正常。我尝试使用escape()
但它没有用,我想不出用PHP来解决这个问题的方法,其他人有什么想法吗?
function editItemInCart(newValue,fieldName,itemNum,cnt) {
//alert(newValue);
if (count == cnt) {
count = 0;
jQuery.ajax({
type:"POST",
url: "editItem.html",
data: "newvalue=" + escape(newValue) + "&fieldname=" + fieldName + "&itemNum=" + itemNum,
})
document.getElementById('status' + itemNum).innerHTML = "SAVED";
jQuery("#status" + itemNum).show();
setTimeout("fade_out('"+itemNum+"')", 1000);
}
//alert(newValue + fieldName + itemNum);
}
if ($cart['title'] != "")
echo "<label>Title: </label> <input type=\"text\" onKeyUp=\"doEditItemInCart(this.value,'title',".$itemNum.")\" onChange=\"editItemInCart(this.value,'title',".$itemNum.")\" value=\"".htmlspecialchars($cart['title'])."\"><br />";
function doEditItemInCart(newValue,fieldName,itemNum) {
count++;
setTimeout("editItemInCart(escape('"+newValue+"'),'"+fieldName+"',"+itemNum+","+count+")",200);
}
答案 0 :(得分:0)
试试这个
jQuery.ajax({type:"POST",
url: "editItem.html?newvalue=" + escape(newValue) + "&fieldname=" + fieldName + "&itemNum=" + itemNum,
})
无论ajax响应如何,您似乎也设置了已保存的状态。我建议添加一个ajax成功函数 http://api.jquery.com/jQuery.ajax/