Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. $.ajax({
  2. url: apiurl,
  3. type: "POST",
  4. crossDomain: true,
  5. xhrFields: {
  6. withCredentials: true
  7. },
  8. contentType: "application/json; charset=utf-8",
  9. dataType: "json",
  10. data: JSON.stringify(form_data)
  11. }).done(function (data) { //on success
  12. console.log("done);
  13. })
  14.  
  15. $curl = curl_init();
  16. curl_setopt($curl, CURLOPT_POST, 1);
  17. curl_setopt($curl, CURLOPT_URL,$apiurl);
  18. curl_setopt($curl, CURLOPT_HTTPHEADER, array(
  19. 'Content-Type: application/json',
  20. ));
  21. curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  22. $result = curl_exec($curl);
  23. return $result;
  24.  
  25. $http_origin = $_SERVER['HTTP_ORIGIN'];
  26. header("Access-Control-Allow-Origin: $http_origin");
  27. // header('Access-Control-Allow-Origin: *');
  28. header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
  29. header('Access-Control-Allow-Credentials: true');
  30. header('Access-Control-Max-Age: 86400');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement