Why send it as an url and not as post data? That should solve it
How to pass a variable with & characters in a post ajax request ?
Hello,
I have a problem with an app I have developed myself, it's a PHP / JS app.
I have a post request sent via ajax and it looks like this.
$.ajax({
type: 'POST',
url : 'index.php?param=value&otherparam=othervalue',
data: 'id=' + id + '&description=' + description + '&' + reponses,
success:function(msg) {
...
}
});
The problem is that the description can contain an html link like this one.
This is my super description.
Here is a link : <a href="https://mydomain.com/index.php?param2=value2&otherparam2=othervalue2">Click here</a>
End of the description ;).
The description variable contains the good value before ajax, but contains a troncated value after ajax in the PHP controller.
This is my super description.
Here is a link : <a href="https://mydomain.com/index.php?param2=value2
The problem is exactly the same if the & is anywhere else, all what is after the & is cut.
I thought perhaps about replacing the & by something else like a unique string (-(-)-) so that I'm sure it will be unique and it won't cause the problem. Then in the PHP controller I can replace (-(-)-) with &.
What do you think about this solution ?
Do you have any other suggestion / idea ?
Thanks for your help ;).
Please or to participate in this conversation.