我想在我的页面上使用Ajax,并通过url传递键值对设置。
xhttp.open("POST", "/ajax/myjsp.jsp?str=key1=value1|key2=value2" , true);
在执行myjsp.jsp上的request.getParameters(“str”)时,它应该给key 1=value 1 x key2=value 2。
It worked as it is posted in my question.The error was it was not getting ajax file path.Just removed / in the beginning and it worked.
function myFunction() {
var uri = "/ajax/myjsp.jsp?str=key1=value1|key2=value2";
var res = encodeURI(uri);
document.getElementById("demo").innerHTML = res;
}
<p>Click the button to encode a URI.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
</div>