2013-02-27 4 views
5

꽤 간단하다XDomainRequest 객체의 내용 유형을 어떻게 설정할 수 있습니까? XMLHttpRequest를위한

var xhr = new XMLHttpRequest(); 
xhr.open('POST', MyUrl, true); 
xhr.setRequestHeader('Content-Type', 'application/json') 

하지만 어떻게 XDomainRequest이 달성합니까?

+0

난 당신이 그렇게 할 수 있다고 생각 해달라고 올바른 헤더와 교차 도메인 스크립트를 미러링하는 로컬 프록시 스크립트를 만들 HTTP를 참조 할 수 있습니다 : // stackoverflow.com/questions/2657180/setting-headers-in-xdomainrequest-or-activexobjectmicrosoft-xmlhttp –

+0

그래서 XDomainRequest가 항상 RAW 데이터를 보내고 내가 보내는 데이터 형식을 정의 할 방법이 없다고 제안합니까? – pencilCake

+0

맞습니다. XDomainRequest는 매우 제한적이므로 여기에서 이러한 제한 사항에 대해 자세히 알아볼 수 있습니다. http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx IE10 CORS에 대한 전폭적 지원을받을 것입니다. – monsur

답변

0

XMLHttpRequest content-type을 재정의 할 수 없습니다. 예를 들어 서버에서 올바르게 설정해야합니다. PHP를위한이 할 수없는 경우

header('Content-type: application/json'); 

는, 당신은 ..

관련 문제