2016-10-04 2 views
0

私はHTML(PHP)体で& -characterを有するenter image description here&-character POST-法による

  1. 次のコードSnippeletsをHACE [グラフィックを参照]

は、私は次のように

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

sendEntryが定義されているボタンでJavascropt-ファイルにこのデータを送信します

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

....私は避けることができますどのように

:結果はAjaxのリクエストに送信され

....

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

... & -charはグラフィックスに示されているように新しいPOSTパラメータを使用しますか?

+0

あなたのデータをエンコードして送信することができます。このリンクはJavaScriptのエンコードに役立ちますhttp://stackoverflow.com/questions/18279141/javascript-string-encryption-and-decryption – Elby

答えて

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

てみてデータをエンコードする;)あなたは、彼らが特殊文字として解釈されないように、あなたがURLに送信している個々の値をエンコードする必要が

0

else{ 
    **PARAMS=PARAMS** + "&Eintrag=" + encodeURIComponent(document.getElementById("Eintrag").value); 
} 

これはすべての値に適用されることに注意してください。例は追加する最後の値です。

関連する問題