jeudi 26 novembre 2015

Get server-side php output through select2 x-editable

I am using select2 v3.5.4 and X-editable v1.5.0

I have an editable using select2 sending data via POST to a PHP script running on server and I am trying to print the server output into the js console. I am attempting this using the success() function but all I get in the Chrome console upon selecting values and hitting the confirmation button, is just undefined.

The Javascript:

$(".sel").editable( {
  source  : [{id: '1', text: 'One'},
             {id: '2', text: 'Two'},
             {id: '3', text: 'Three'}],
  select2 : {multiple: true},
  url     : "animalsDetailsEdit.php",
  dataType: 'JSON',
  success : function(response, newValue) {
              console.log(response);
            },
  error   : function(){
              console.log("Error");
            }
});

The serverside PHP:

<?php
  echo json_encode("TEST MESSAGE");
?>

I have tried multiple combinations of paramaters but to no avail.




Aucun commentaire:

Enregistrer un commentaire