i have an input element with & in value:
<input type="checkbox" value="Biografie, životopisy, osudy, Domácí rock&pop" />
When i try sending it through an ajax request:
$.ajax({
type: "POST",
url: "/admin/kategorie/add/link.json",
data: "id="+id+"&value="+value+"&type="+type,
error: function(){alert('Chyba! Reloadněte prosím stránku.');}
});
the post data that actually gets sent is:
id: 1
pop:
type: e
value: Biografie, životopisy, osudy, Domácí rock
*Note that all the variables in data are defined and value contains $(thatInputElement).attr('value').
How can I escape the &
properly so that post field value
would contain Biografie, životopisy, osudy, Domácí rock&pop
?
We can try to forget ourselves by becoming fully absorbed in an activity, for instance, watching a film, playing a game, or working on a project. Some people opt to take various drugs that can alter one's states of consciousness. Such techniques can provide a respite, but the effects are temporary.
There is no “best” activity to help you mentally escape reality; however, you should always do something that you enjoy. Some people may find the best way to mentally escape reality is to go skydiving or snorkeling, while others may enjoy playing a computer game or putting together a puzzle.
Taking a step back from reality is a very effective way of experiencing a few moments of respite to help cope with life's hardships. When escapism is helpful, it is when we take a moment to step out of our reality and experience a period of escape from the challenges of our lives.
You can set your data
option as an object and let jQuery do the encoding, like this:
$.ajax({
type: "POST",
url: "/admin/kategorie/add/link.json",
data: { id: id, value: value, type: type },
error: function(){ alert('Chyba! Reloadněte prosím stránku.'); }
});
You can encode each value using encodeURIComponent()
, like this:
encodeURIComponent(value)
But the first option much simpler/shorter in most cases :)
Have you tried this syntax?
data: {"id":id, "value": value, "type": type }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With