2011-03-29 1 views
0

나는이 jQuery 코드로 http://subdomainA.domain.com/insert.htm 있습니다jQuery를 WCF 데이터 서비스 크로스 도메인 레코드를 삽입

 // JSONify the data 
     var data = JSON.stringify(data); 

     // Post it 
     $.ajax({ 
      type: "POST", 
      contentType: "application/json; charset=utf-8", 
      url: "http://subdomainB.domain.com/myservice.svc/Surveys", // trying to insert record to wcf data service 
      data: data, 
      dataType: "json", 
      success: function(){ // success} 
     }); 

내가 '액세스 거부'를 얻을. 이것이 할 수있는 방법이 있습니까?

+0

서비스가 도메인 간 요청을 허용하는 경우 'jsonp'도 옵션 – Rafay

+0

이며 jsonp를 허용합니다. jsonp를 통해이 작업을 수행하는 방법을 보여줄 수 있습니까? – dm80

답변

0

크로스 도메인 (또는이 경우 하위 도메인) 통신을 수행하는 subdomainA에 프록시를 만드는 것입니다. jQuery ajax를 통해 호출 할 subdomainA에 서비스를 작성하면 서버 측 코드로 모든 크로스 도메인 작업을 수행 할 수 있습니다. IMO 이것은 가장 안전하고 미래적인 증명 옵션입니다.