I am working on an simple client/server communication with jquery/JS and PHP. It works fine till a '.' is included in the data.
Tried with the following titles:
asdf-wq1 --> workstest1 --> worksbigip1.local --> '.' is replaced with '_'
I already added the escape() function to my code, but the result was the same.
function xy(){
for (var i = 0; i < nodes.length; i++) {
var xy = escape(nodes[i].title) +"=" +escape(nodes[i].translate.x + "/" + nodes[i].translate.y);
$.ajax({
url: 'save_layout.php',
data: xy,
dataType: "text",
type: 'post',
success: function(output) {
$("#output").html(output);
},
error: function (response, status, error) {
alert("error" + response.responseText);
}
});
}
}
PHP:
foreach($_POST as $name=>$value) {
echo "$name $value \n";
}
Firebug Output Request:
POST http /frontend/save_layout.php 200 OK 186ms jquery....min.js (Zeile 4) HeaderPostAntwortHTML Parameterapplication/x-www-form-urlencoded bigip1.local 470/390 Quelle bigip1.local=470/390
Firebug Output (Response):
bigip1_local 470/390
As you can see - it seems to be sent to the server correctly, but on the server as soon as reading our of $_POST - the '.' is a '_' at a sudden.
Hope someone can help me here!
var xy = {}; xy[nodes[i].title] = nodes[i].translate.x + "/" + nodes[i].translate.y;That way jQuery will string the post body for you.