I have a problem with the following snip of code:
$.ajax(
{
type: "POST",
url: "AjouterAttribut.php",
data: { val: valvaleur, table: nomvaleur }
}).success(function(message)
{
var rep = $.trim(message);
if (rep == '-')
{
$.unblockUI();
alert("Cet enregistrement existe déjà");
}
else
{
var Tableau = jQuery.parseJSON(rep);
boutonappuye.prev().find('option').remove();
boutonappuye.next().attr("disabled", "true");
boutonappuye.next().find('img').attr('src', 'images/Supprimer_nonactif.png')
for (var i=0; i< Tableau.length; i++)
{
boutonappuye.prev().append("<option value="+ Tableau[i][0] +">" + Tableau[i][1] + "</option>");
}
$.unblockUI();
}
});
This line, specifically:
var Tableau = jQuery.parseJSON(rep);
This works on Firefox 12. However, I need to make it compatible on Firefox 3.6. Much to my dismay, the javascript just crashes there. I tried doing an alert of the contents of the rep variable right before that line. It gave this:
[["1","Etudiant"],["3","Etudiant privilege"],["2","Professeur"],["7","wrerew"]]
If I change the line of code above for:
var Tableau = jQuery.parseJSON('[["1","Etudiant"],["3","Etudiant privilege"],["2","Professeur"],["7","wrerew"]]');
It works. I’m not even sure why putting the variable in the function causes it to crash.
Thank you~
It was a problem with the encoding, my php file was encoded in UTF-8 with BOM. Had to encode it without.