1

We are trying to user ajax to make a call to a webservice - Authentication/Validate but so far, it can't find the webservice.

Each time you run the script, you get, "error", just error.

The webservice is on a different web server while the ajax script calling it is on another server.

However, they are both on port 80 and on same domain.

I have been struggling with this for 2 days.

Script is below.

Thanks alot in advance

<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$.ajax({
      url:"Authentication/Validate",
     data: { data: JSON.stringify({ LoginName: "jane.doe",Password: "jdoe" }) },
     success: function (data) {
             alert("found!");
             debugger;
             var token = JSON.parse(data);
     },
     error: function(a,b,c) {
       alert(b+"\n"+c)
     },
     dataType:"json"
});
</script>
</head>
<body></body>
</html>



param=data: {"LoginName":"jane.doe","Password":"jdoe"}

Response body: SyntaxError: JSON.parse: Unexpected end of data
4

1 回答 1

0

有效的文件 URL 以 开头file://,但文件不会以非常有用的方式回答您的 AJAX 响应。

您需要并且他们需要提供 Web 服务的有效 URL。类似的东西http://domain.com/somePath

看:

于 2013-11-14T19:40:08.467 回答