Reputation: 63349
I have an xml string that wanted to be sent to server:
<script type="text/javascript">
$(document).ready(function() {
// put all your jQuery goodness in here.
$('#button').click(function() {
$.post('http://localhost/a.bc', { cmd:"<cmd cmd_name='login_user'><login_user user_name='binc1' password='pp'/></cmd>"}, function(data) {
alert(data);
$('.result').html(data);
});
});
});
</script>
The white space inside the xml is replaced to '+' when server got it. Is it possible that I can escape the xml by myself before use $.post so that it will send the escaped version to server. I can unescape the string in the server side.
Or even better, can I send pure XML to server without any escape/unescape dirty things?
Upvotes: 1
Views: 8192
Reputation: 10502
If you want to escape the string, the JavaScript escape() function is at your disposal.
Upvotes: 4
Reputation: 161
You could just use a JavaScript function like encodeURIComponent. Check out the link below for usage and examples.
http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp
Upvotes: 2