php - Ajax error when retrieving data from JSON -
I am trying to send data to my PHP file which includes values in DB (this part is fine) And then send back JSON. Encoded data in a javascript file, so that I can display them, but this is not working. I do not know what's actually wrong. I'm looking at many work examples and mines are not working
$ AZ ({type: "post", datatype: "jason", url: "requete.php", data: data, breakthrough: function (data) {if (data. Success == true) {warning (data. ;}}, Error: function (error thrown) {warning ('error');}});
The data is correctly sent to PHP and inserted in DB but the following JSN will not be displayed:
if (isset ($ _ POST) ['Action']) & Amp; $ _POST ['action'] == 'add_attribution') {$ nom = $ _POST ['name']; $ Date = $ _POST ['date']; $ Montant = (int) $ _ POST ['montant']; $ Type = utf8_decode ($ _ POST ['type']); Enter $ Sql = "BO_DEPENCE (Montant, date, place, description, carte) value ('$ montent', '$ date', '', '$ name', '$ type')"; $ Result = mysql_query ($ sql); $ Data = array ('success' = & gt; true, 'message' = & gt; 'success message: hooray!'); Echo json_encode ($ data);
With this code, the console returns the "object" with the data sent to the console PHP / MySql (??)
) Warning (obj);
It turns out that it displays the first values sent to my php script (to include in DB), and not that I'm JSON encoded ... why?
Try to use
if ($ .trim ( Data.success) == 1)
Sometimes I have encountered the only situation that I have solved
Comments
Post a Comment