41
rated 0 times
[
47]
[
6]
/ answers: 1 / hits: 158319
/ 12 Years ago, mon, july 2, 2012, 12:00:00
I want to send a few variables and a string with the POST
method from JavaScript.
I get the string from the database, and then send it to a PHP page. I am using an XMLHttpRequest
object.
The problem is that the string contains the character &
a few times, and the $_POST
array in PHP sees it like multiple keys.
I tried replacing the &
with &
with the replace()
function, but it doesn't seem to do anything.
Can anyone help?
The javascript code and the string looks like this:
var wysiwyg = dijit.byId(wysiwyg).get(value);
var wysiwyg_clean = wysiwyg.replace('&','&');
var poststr = act=save;
poststr+=&titlu=+frm.value.titlu;
poststr+=§iune=+frm.value.sectiune;
poststr+=&wysiwyg=+wysiwyg_clean;
poststr+=&id_text=+frm.value.id_text;
xmlhttp.open(POST,lista_ajax.php,true);
xmlhttp.setRequestHeader(Content-type,application/x-www-form-urlencoded);
xmlhttp.send(poststr);
The String is:
<span class=style2>"Busola"</span>
More From » ajax