Javascript 使用:eq()选择器时缺少字符串
我使用jQuery从中读取字符串并将其传递到PHP中,然后插入/编辑数据库。 我的问题是,在这个过程中,我丢失了大字符串,它们永远不会保存到数据库中,我无法编辑它们!我有一个大字符串,我不能编辑它。代码崩溃了 对字符串大小有:eq()选择器限制强> 我选择字符串的代码是:Javascript 使用:eq()选择器时缺少字符串,javascript,php,jquery,string,Javascript,Php,Jquery,String,我使用jQuery从中读取字符串并将其传递到PHP中,然后插入/编辑数据库。 我的问题是,在这个过程中,我丢失了大字符串,它们永远不会保存到数据库中,我无法编辑它们!我有一个大字符串,我不能编辑它。代码崩溃了 对字符串大小有:eq()选择器限制 我选择字符串的代码是: $(document).on("click",".edit_button",function() { $(this).parents("tr").each(function(index) { $("*").c
$(document).on("click",".edit_button",function() {
$(this).parents("tr").each(function(index) {
$("*").css("cursor", "wait");
id = $(this).find("td").eq(0).text();
comment = $(this).find("td").eq(1).text();
$.ajax({
type: 'GET',
url: 'ajax.php',
data:{ comment : comment , job : "edit"},
dataType:"html",success:function(result){
$("*").css("cursor","auto");
$(".edit_button").css("cursor", "pointer");
document.getElementById("items_body").innerHTML=result;
}
});
});
});
文件ajax.PHP中的PHP代码是:
$job=$_GET["job"];
if ($job=="edit")
{
$comment=$_GET["comment"];
$id=$_GET["id"];
$sql_command="UPDATE items SET comment='$comment' WHERE id='$id'";
mysql_query($sql_command,$con);
}
您没有在ajax调用中传递
id
data:{ comment : comment , job : "edit", id : id },
eq()
没有限制,限制是get方法。所以最好使用post
尝试使用post方法发送请求。Get方法在发送数据时有一些限制。