Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. $(document).ready(function() {
  2. $("#ajaxform1").submit(function(e){
  3. e.preventDefault();
  4. var surl = "http://blahblah/test_create_user.php?callback=?";
  5.  
  6. $.ajax({
  7. type: 'GET',
  8. url: surl,
  9. crossDomain: true,
  10. data: $('#ajaxform1').serialize(),
  11. dataType: "jsonp",
  12. success: function(msg) {
  13.  
  14. $.each(msg, function (index, value) {
  15. if(value==1)
  16. {
  17. alert("New User Added");
  18. } else {
  19. alert("User Already Exists")
  20. } }
  21. });
  22.  
  23. },
  24. error: function(xhr, status, error) {
  25. var myerror = xhr+" "+status+" "+error;
  26. alert("Failure Connecting to Kayako. Please Try Again("+myerror+")"); }
  27.  
  28. });
  29.  
  30. if($USER_CHK->first()->id){
  31. $data = array('msg' => '0'); // user exists
  32. else {
  33. $data = array('msg' => '1'); // User added
  34. }
  35. //echo customerAdded(FALSE);
  36. header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
  37. header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
  38. header('Access-Control-Max-Age: 1000');
  39. header('Access-Control-Allow-Headers: Content-Type, Authorization,X- Requested- With');
  40. header("Content-type: application/json");
  41. $data = array('msg' => '0');
  42. print $_REQUEST['callback']. '('.json_encode($data).')';
  43. exit;
  44.  
  45. });
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement