duanpanhuo0618 2016-10-04 07:53
浏览 22

通过POST方法在Ajax-Requests中使用&字符

I hace the following code-Snippeletsenter image description here

  1. I have an &-character in a HTML(PHP)-form [see Graphics]

I send this data to a Javascropt-file by a button

<button onclick="sendEntry()" > Senden </button>

sendEntry is defined as follows:

....

  if(document.getElementById("Eintrag").value==""){
        ERROR= ERROR + "Kein Eintrag eingegeben
";             
    }
    else{
        **PARAMS=PARAMS** + "&Eintrag=" + document.getElementById("Eintrag").value; 
     }

...

the result is sent to a Ajax-request:

ajaxRequest.open("POST", "./../php/MakeEntry.php", true);
    ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    ajaxRequest.send(PARAMS);

....

How can I avoid that the &-char auses a new POST-Parameter as shown in the Graphics ??

  • 写回答

2条回答 默认 最新

  • dsiy62758 2016-10-04 07:57
    关注
    ajaxRequest.open("POST", "./../php/MakeEntry.php", true);
    ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    ajaxRequest.send(encodeURI(PARAMS));
    

    Try to encode your data ;)

    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败