Salve a tutti, ho un problema a passare dati da php a jquery tramite il formato json...ò
Da jquery faccio richiesta al file php in questa maniera:
codice:
$.ajax({
chache: false,
type: "POST",
url: "../libraries/php/ajax/tabelle.php",
dataType: "json",
data: "",
success: function(msg){
$.each(msg, function(key,state) {
alert(state);
});
},
error:function(XMLHttpRequest,status,error){
alert("Error: "+error);
}
});
Dal php questo è ciò che ottengo da: echo json_encode($stringa);
"{tabella:{name:\"comuni\",restrizione:\"\",campi: {campo:{name:\"id\",notnull:\"1\",tipo:\"int\"},ca mpo:{name:\"nome\",notnull:\"1\",tipo:\"blob\"},ca mpo:{name:\"province\",notnull:\"1\",tipo:\"int\"} }},tabella:{name:\"errori\",restrizione:\"\",campi :{campo:{name:\"id\",notnull:\"1\",tipo:\"int\"},c ampo:{name:\"comuni\",notnull:\"1\",tipo:\"int\"}} },tabella:{name:\"province\",restrizione:\"\",camp i:{campo:{name:\"id\",notnull:\"1\",tipo:\"int\"}, campo:{name:\"nome\",notnull:\"1\",tipo:\"blob\"}, campo:{name:\"regioni\",notnull:\"1\",tipo:\"int\" }}},tabella:{name:\"regioni\",restrizione:\"\",cam pi:{campo:{name:\"id\",notnull:\"1\",tipo:\"int\"} ,campo:{name:\"nome\",notnull:\"1\",tipo:\"blob\"} ,campo:{name:\"descrizione\",notnull:\"1\",tipo:\" blob\"},campo:{name:\"video\",notnull:\"1\",tipo:\ "blob\"}}},tabella:{name:\"restrizioni\",restrizio ne:\"1\",campi:{campo:{name:\"id\",notnull:\"1\",t ipo:\"int\"},campo:{name:\"tipo\",notnull:\"1\",ti po:\"blob\"},campo:{name:\"nome\",notnull:\"1\",ti po:\"blob\"},campo:{name:\"restrizioni\",notnull:\ "1\",tipo:\"int\"}}},tabella:{name:\"strutture\",r estrizione:\"\",campi:{campo:{name:\"id\",notnull: \"1\",tipo:\"int\"},campo:{name:\"nome\",notnull:\ "1\",tipo:\"blob\"},campo:{name:\"comuni\",notnull :\"1\",tipo:\"int\"},campo:{name:\"stelle\",notnul l:\"1\",tipo:\"int\"},campo:{name:\"tel\",notnull: \"1\",tipo:\"blob\"},campo:{name:\"fax\",notnull:\ "1\",tipo:\"blob\"},campo:{name:\"indirizzo\",notn ull:\"1\",tipo:\"blob\"},campo:{name:\"cap\",notnu ll:\"1\",tipo:\"blob\"},campo:{name:\"sito\",notnu ll:\"1\",tipo:\"blob\"},campo:{name:\"email\",notn ull:\"1\",tipo:\"blob\"},campo:{name:\"selezionato \",notnull:\"1\",tipo:\"int\"}}},tabella:{name:\"u sers\",restrizione:\"1\",campi:{campo:{name:\"id\" ,notnull:\"1\",tipo:\"int\"},campo:{name:\"usernam e\",notnull:\"1\",tipo:\"blob\"},campo:{name:\"psw d\",notnull:\"1\",tipo:\"blob\"},campo:{name:\"ema il\",notnull:\"1\",tipo:\"blob\"},campo:{name:\"ty pe\",notnull:\"1\",tipo:\"int\"}}}}"