1
다른 사이트의 페이지에 XMLHttpRequest를 호출하는 페이지가 있습니다. 그냥 날짜와 시간 문자열을 에코,상태를 반환하는 교차 사이트 xmlhttp 요청 0
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML Template</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Generator" content="Dev-PHP 2.6.0" />
<meta name="Keywords" content="your,keywords,here" />
<meta name="Description" content="." />
</head>
<body>
<p>
<input type="text" name="txtReturn" id="txtReturn" size=75 />
</p>
<textarea name="taStatus" id="taStatus" cols="75" rows="25"></textarea>
<p> </p>
<script type="text/javascript">
function getReturn()
{
var txtBox = document.getElementById("txtReturn");
var taStatus = document.getElementById("taStatus");
txtBox.value = "Preparing to get Response";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
// alert('IE7+, Firefox, Chrome, Opera, Safari');
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
// alert('IE6, IE5');
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
taStatus.innerHTML = taStatus.innerHTML + "URL: " + url + ".\nReadyStatus: " + xmlhttp.readyState + ".\nStatus: " + xmlhttp.status + ".\nStatusText: " + xmlhttp.statusText + ".\nresponseText: " + xmlhttp.responseText + ".\n\n";
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
// alert(xmlhttp.responseText);
txtBox.value = xmlhttp.responseText;
// alert(xmlhttp.responseText);
}
}
var url = 'http://www.ip.com.om/site/checkdata.php';
var url2 = 'http://badihbarakat.com/site/checkdata.php';
var url3 = '../site/checkdata.php';
xmlhttp.withCredentials = true;
// url = url + ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime();
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
getReturn();
</script>
</body>
</html>
다른 사이트에 호출 된 .PHP 페이지 : 문제는, 반환 된 상태는 0 발신자 페이지의 코드입니다.
누구든지 문제를 제기 할 수 있습니까? 나는 파이어 폭스 (27)를 사용하고 난 오류 브라우저를 확인하고 그것을 보여주고있다 :
**GET http://www.ip.com.om/site/checkdata.php [HTTP/1.1 200 OK 710ms]**
을 당신이 그것을 클릭하면, 요청의 세부 사항을 보여줍니다
Request URL: http://www.ip.com.om/site/checkdata.php
Request Method: GET
Status Code: HTTP/1.1 200 OK
**Request Headers 17:27:37.000**
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
Referer: http://badihbarakat.com/local/
Origin: http://badihbarakat.com
Host: www.ip.com.om
Connection: keep-alive
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
**Response Headers Δ710ms**
X-Powered-By: PHP/5.3.26
X-CFLO-Cache-Result: TCP_REFRESH_MISS
Server: Apache
Date: Sat, 01 Mar 2014 13:27:42 GMT
Content-Type: text/html
Content-Length: 37
Connection: Keep-Alive
Age: 0
여러분의 소중한 답변을 기다리는 중 .. .
Badih Barakat
따라서 호출 된 페이지의 결과를 얻는 것도 불가능합니다. – BadihBarakat
나는 참고 URL [link] (http://www.leggetter.co.uk/2010/03/12/making-cross-domain-javascript-requests-using-xmlhttprequest-or-xdomainrequest)에서 코드를 시도했다. html)'XMLHttpRequest 또는 XDomainRequest'를 사용하여 크로스 도메인 자바 스크립트 요청하기 – BadihBarakat
현재 작동 중입니다 ... 누락 된 부분은 .php 파일에 있습니다 ... 참고로 많은 감사드립니다 ... :) – BadihBarakat