Guest User

Untitled

a guest
Mar 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. var uri = "http://localhost/aniadir.php"
  2. $.ajax({
  3. url: uri,
  4. data: data,
  5. method: "POST",
  6. dataType:"json",
  7. async: true,
  8.  
  9. success: function (response) {
  10.  
  11. console.log("OK" + response.data.message);
  12.  
  13.  
  14.  
  15. },
  16. error: function (xhr, textStatus, errorMessage) {
  17.  
  18. console.log("ERROR" + errorMessage + textStatus + xhr);
  19.  
  20. }
  21. }); // end ajax
  22.  
  23. $mysqli = new mysqli('localhost', 'root', 'error', 'tabla');
  24.  
  25. $jsondata["success"] = false;
  26. $jsondata["data"] = array(
  27. 'message' => $mysqli->error
  28. );
  29.  
  30. header('Content-type: application/json; charset=utf-8');
  31. echo json_encode($jsondata, JSON_FORCE_OBJECT);
Add Comment
Please, Sign In to add comment