javascript - 使用 :eq() Selector 时字符串丢失

标签 javascript php jquery string

我使用 jQuery 读取字符串并将其传递给 PHP,然后插入/编辑数据库。 我的问题是,在此过程中,我丢失了大字符串,它们永远不会保存到数据库,而且我无法编辑它们!我有一个很大的字符串,我无法编辑它。代码崩溃了!

:eq() 选择器对字符串大小有限制吗?!

我选择字符串的代码是:

 $(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 },

There is no limitation for eq(), limitation is for get method. So it's better to use post instead.

关于javascript - 使用 :eq() Selector 时字符串丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30411293/

相关文章:

php - 无法将 facebook 包含在我的 codeigniter 项目中

php - 将属性声明为对象?

java - 不同格式的 Axis SOAP 响应是否相同?

javascript - 使用选择选项值更改表格填充

javascript - 在加载时设置选择元素的选项样式

javascript - 如何组织多个复选框?

javascript - cakephp - 电子邮件的验证规则是什么

javascript - 溢出-x :hidden; can still scroll when open at my phone

javascript - MVC 中的 JQuery - 使用 getJson 将表单数据作为数组发送

javascript - 表格排序器 : Mouseover not working after applying sorting on table