我想使用谷歌地图显示一些GPS坐标。我在ajax查询中使用Web服务。我面临的问题是当我在IIS上部署应用程序时,Web服务不起作用,而在未部署时它可以正常工作。也许我必须先做一些特别的事情,但这很奇怪。 这是我的代码:
网络服务
<WebMethod()>
Public Function Test(ByVal idinst As String) As String
Dim entites As New epgar_formEntities
Dim jss As New JavaScriptSerializer
Dim listPatient As New List(Of A5349_DOT_DAILY_REPORT_BY_PROJECT_Result)
Dim patient As New A5349_DOT_DAILY_REPORT_BY_PROJECT_Result
listPatient = DalManager.DailyReportByProject(idinst)
Dim query As New List(Of A5349_DOT_DAILY_REPORT_BY_PROJECT_Result)
query = From o In listPatient Select o.LATITUDE, o.LONGITUDE, o.AGENT
Return jss.Serialize(query)
End Function
Ajax查询:
$.ajax({
type: "POST",
url: "webservice.asmx/" + webmethod,
data: JSON.stringify({idinst:'' + project}),
dataType: "json",
contentType: "application/json",
success: function (data) {
var rs = JSON.parse(data.d);
for (var i = 0; i < rs.length; i++) {
putMarker(rs[i]['LATITUDE'], rs[i]['LONGITUDE'], "Marker Test", "images/marker_rouge.png");
}
},
error: function (jQXHR, textStatus, errorThrown) {
alert("An error occurred whilst trying to contact the server: " + jQXHR.status + " " + textStatus + " " + errorThrown);
}
});
然而,这有效。
<WebMethod()>
Public Function Test(ByVal idinst As String) As String
Dim entites As New epgar_formEntities
Dim jss As New JavaScriptSerializer
Dim listPatient As New List(Of A5349_DOT_DAILY_REPORT_BY_PROJECT_Result)
patient.LATITUDE = "18.32344"
patient.LONGITUDE = "-72.79875"
patient.AGENT = "user"
patient1.LATITUDE = "18.32344"
patient1.LONGITUDE = "-72.79875"
patient1.AGENT = "user"
patient2.LATITUDE = "18.32344"
patient2.LONGITUDE = "-72.79875"
patient2.AGENT = "user"
listPatient.add(patient)
listPatient.add(patient1)
listPatient.add(patient2)
query = From o In listPatient Select o.LATITUDE, o.LONGITUDE, o.AGENT
Return jss.Serialize(query)
End Function
如果您有任何想法,请非常欢迎您。