samedi 18 avril 2015

XMLHttpRequest cannot load and Uncaught NetworkError

I'm working on a clientside project with jquery and javascript along with using jquery plugins. Our professor provided us with a proxy.php file to pull in data that we need to run the web app. I used the easy tab plugin which imported the jquery.min.js file. But I keep getting an error and the proxy.php file fails to load.


Here is the proxy.php file.



<?php
error_reporting(0);
define ('HOSTNAME', 'http://ift.tt/1Jg5eMF');
if($_POST['path']){
$hold=explode('?',$_POST['path']);
$path=$hold[0];
$post=$hold[1]."&ip=".$_SERVER['REMOTE_ADDR'];
$url= HOSTNAME.$path;
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session,CURLOPT_POST,1);
curl_setopt($session,CURLOPT_POSTFIELDS,$post);
}else{
$url=HOSTNAME.$_GET['path'];
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
}
$xml = curl_exec($session);
header("Content-Type: text/xml");
echo $xml;
curl_close($session);
?>


These are the errors I keep getting. How do I fix this?


XMLHttpRequest cannot load file:///C:/Users/Kubra/Desktop/Project2/proxy.php?path=%2FCities%3Fstate%3DNY&_=1429379822193. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. jquery.min.js:6


Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/Users/Kubra/Desktop/Project2/proxy.php?path=%2FCities%3Fstate%3DNY&_=1429379822193'.


Aucun commentaire:

Enregistrer un commentaire