UPDATE1:如何調用跨域的WebService/WCF在JQuery中
這裏是當我複製並粘貼到IE瀏覽器的服務URL是什麼我得到:
的http:// myservername /myservices.svc?wsdl
- <wsdl:message name="ILodge_GetCountfor">
<wsdl:part name="parameters" element="tns:GetCountfor" />
</wsdl:message>
- <wsdl:message name="ILodge_GetCountfore">
<wsdl:part name="parameters" element="tns:GetCountfor" />
</wsdl:message>
- <wsdl:message name="ILodge_GetCountfor_Input">
<wsdl:part name="parameters" element="tns:GetCountfor" />
</wsdl:message>
- <wsdl:message name="ILodge_GetCountfor">
<wsdl:part name="parameters" element="tns:GetCountfor" />
</wsdl:message>
HTTP://myservername/myservices.svc XSD = xsd0
- <xs:element name="GetCountfor">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="GetCountforResult" type="xs:long" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="GetCountfor">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="Id" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="LevelId" type="xs:long" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="GetCountfor">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="GetCountfor" type="xs:long" />
</xs:sequence>
</xs:complexType>
</xs:element>
UPDATE:
我看到服務正在恢復我作爲XML:
public override string ToString()
{
//- <name>CLUE</name><desc>CLUE list</desc>
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
sb.AppendLine("<kml xmlns=\"someSITE">");
sb.AppendLine("<FOLDER>");
sb.AppendLine("<name>Clue</name>");
sb.AppendLine("<desc>Clue list</desc>");
sb.AppendLine("</FOLDER>");
sb.AppendLine("</kml>");
return sb.ToString();
}
我嘗試了多種不同的方式來執行以下跨域參考,但沒有成功...什麼我做錯了嗎?我嘗試調試,並把斷點,但看起來像它永遠不會執行
$(document).ready(function() {
$.getJSON("http://servername/tools/myservice.svc/mymethod/?Id=1&callback=?", null,
function (result) {
alert("in test: " + result);
debugger
$("#spText").html(result);
});
OR
var path = "http://servername/tools/myservice.svc/mymethod?Id=1&callback=?";
$.ajax({
type: "GET",
url: path,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (response) {
debugger
if (response != null) {
//displayData(response);
}
}
});
OR
debugger
$.ajax({ url: "http://servername/tools/myservice.svc/mymethod",
data: { Id: "1" },
dataType: "jsonp",
success: function (json, textStatus) {
alert(json.d);
alert(textStatus);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger
}
});
OR
$.ajax({
type: "GET",
cache: false,
url: "http://servername/tools/myservice.svc/mymethod/Id=1&callback=?",
scriptCharset: "utf-8",
dataType: "jsonp",
data: parameters,
success: function (data, textStatus) {
debugger
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger
}
});
}
[訪問被拒絕使用jquery-1.4.1.js](http://stackoverflow.com/questions/4146650/access-is-denied-using-jquery-1-4-1-js) – lonesomeday 2010-11-15 19:29:46
請修改現有問題,而不是在發佈相同問題時發佈新問題。 – lonesomeday 2010-11-15 19:30:11
我不會在發佈的問題中獲取拒絕訪問錯誤。 – 2010-11-15 19:33:48