I want to launch an ajax
:
var tel = "+26132".concat($('#tel_id').val());
var donne = "num="+tel;
var ret = $.ajax({
data: donne,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/verifierTelAjax.php",
async: false
}).responseText;
if ( $.trim(ret) == "oui" )
return true;
else
return false;
When I debugged then I see that the num
post variable does not have the "+" sign when the ajax script is called !
So how to make the sign "+" be gotten ?
Use:
data: {num: tel}
To apply URL encoding.
Or manually: var tel = encodeURIComponent("+26132".concat($('#tel_id').val()));
You can let jQuery format it for you automatically for you if you pass the data as an object
var donne = {num:tel};
var ret = $.ajax({
data: donne,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/verifierTelAjax.php",
async: false
}).responseText;