【问题标题】:Submit form and a textarea on ajax post在 ajax 帖子上提交表单和文本区域
【发布时间】:2014-02-16 22:19:53
【问题描述】:

我想在我的 ajax 帖子上提交一个表单和另一个文本区域,可以吗?这是我的代码

<script>
function updateuseracc(form, password)
{   
    var p = document.createElement("input");

    form.appendChild(p);
    p.name="p";
    p.type="hidden";
    p.value=hex_sha512(password.value);
    password.value="";

    var email=$("#curemail").val();

    $.post('updateuser.php',$('#myform').serialize(),textarea:textarea),(function(data){
    });
}
</script>

我只是遇到了错误

【问题讨论】:

  • 我的回答解决了你的问题吗?如果是,请将其标记为答案,以便其他人可以看到。

标签: javascript php jquery html ajax


【解决方案1】:

第一个 textarea 不是变量。如果您想获得它的价值,请执行以下操作:

var  text = $(textarea).text ();

将数据放在大括号中,函数是第三个参数。

$.post('updateuser.php', {
            form:$('#myform').serialize(),
            textarea:text},
      function(data){
    //code...
});

此外,您应该注意服务器端的任何安全功能!

http://api.jquery.com/jquery.post/

【讨论】:

  • @user3196424 - 你能更详细地描述它没有工作吗?你收到什么错误?你期望得到什么?
猜你喜欢
  • 1970-01-01
  • 2013-11-07
  • 1970-01-01
  • 2023-04-04
  • 1970-01-01
  • 2020-09-26
  • 1970-01-01
  • 2017-01-24
  • 1970-01-01
相关资源
最近更新 更多