I have a contact edit form.
The entire form is requested through ajax (loaded into a lightbox).
The form is preloaded with the contacts data.
When you click edit jQuery checks for the differences in the form and sends only the changed inputs back.
This works fine except.
on localhost doing echo $_POST['data'] gives [{"name":"firstName","value":"James"}]
doing it on production gives [{\"name\":\"firstName\",\"value\":\"James\"}]
Where are the extra \ coming from.
If it helps
localhost = windows, php 5.3
production = linux php 5.2
let me know if you need any more code
var contact = $(this).attr('rel');
$.facebox(function() {
$.ajax({
url: site_url + 'ajax/contact',
type: 'POST',
data: {
id: contact,
method: 'editForm'
},
success: function(data) {
$.facebox(data);
$('#editForm').submit(function() {
var data = [];
var finalForm = $(this).serializeArray();
var differences = 0;
for (var i in initialForm) {
if (!objectsAreSame(initialForm[i], finalForm[i])) {
data[differences] = finalForm[i];
differences++;
}
}
if (differences > 0) {
$.ajax({
url: site_url + 'ajax/contact',
type: 'POST',
data: {
id: finalForm[0].value,
method: 'editContact',
data: JSON.stringify(data)
},
success: function(data) {
$('#contact' + finalForm[0].value).hide("drop", {direction: 'up'}, 500,
function() {
$('#contact' + finalForm[0].value).replaceWith(data);
$('#contact' + finalForm[0].value).show("drop", {direction: 'up'}, 500, function() {
$(document).trigger('close.facebox');
});
});
return false;
}
});
}
$(document).trigger('close.facebox');
return false;
});
$('#accordion').accordion();
initialForm = $('#editForm').serializeArray();
}
});
});
Have a look at http://php.net/manual/en/security.magicquotes.php . On you development machine, since you are running 5.3.0 they are deprecated. On your production machine they are enabled. Check on how to disable them but be sure to double-check your code.