I hace the following code-Snippelets
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 ??
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 ;)
You need to encode the individual values that you are sending in the url so that they will not be interpreted as special characters:
else{
**PARAMS=PARAMS** + "&Eintrag=" + encodeURIComponent(document.getElementById("Eintrag").value);
}
Note that this applies to all values, the example is just for the last one you are adding.