So I have a php file called paste.php in a directory in a server with domain example.com (http://www.example.com/ajax/paste.php) The php file looks like:
<?php $id=($_GET['create']); $paste=($_GET['paste']); $toly=($_GET['toly']); if($id=='create'){ echo "hello";} else{ echo "world"; } ?> In another server with different domain i have a simple html file (www.example/demo/index.html) I 'am trying to make an ajax call to the php file above with no luck My jquery looks like:
var url="http://www.example.com/ajax/paste.php"; s="create=create&paste=hello&toly=this"; $.ajax({ type: "GET", xhrFields: { withCredentials: true }, url: url, data: s, success: function(msg){ alert(msg); },error:function (jqXHR){ alert(jqXHR.status.error); } }); What am I doing wrong?
EDIT : Forget the xhr i just want to get back the string i have made as a response Is there any way?