Guest User

Untitled

a guest
Jul 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. function save($data)
  2. {
  3. $allData = load();
  4. array_push($allData, $data);
  5. global $filePath;
  6. $fp = fopen($filePath, 'w+') or die("I could not open $filePath.");
  7. fwrite($fp, serialize($allData));
  8. echo "{status:"success" , result:" . (string)(count($allData) - 1) . "}";
  9. fclose($fp);
  10. }
  11.  
  12. $jQuery.ajax({
  13. url: serverUrl,
  14. type: "GET",
  15. data: {method: "save", data: jQuery.param(pData)},
  16. cache: false,
  17. success: function (data) {
  18. alert("data");
  19. }
  20. });
  21.  
  22. echo '{"status": "success", "result": "'. (string)(count($allData) - 1) .'"}';
  23.  
  24. alert(data.status);
  25.  
  26. $jQuery.ajax({
  27. url: serverUrl,
  28. type: "GET",
  29. data: {method: "save", data: jQuery.param(pData)},
  30. dataType: 'json', //added by me
  31. cache: false,
  32. success: function (data) {
  33. alert("data");
  34. }
  35. });
  36.  
  37. $var = array('status' => 'success', 'result' => count($allData) - 1 );
  38. echo json_encode($var);
Add Comment
Please, Sign In to add comment