Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs $http仅在发出简单ajax请求时调用错误?_Angularjs - Fatal编程技术网

Angularjs $http仅在发出简单ajax请求时调用错误?

Angularjs $http仅在发出简单ajax请求时调用错误?,angularjs,Angularjs,我觉得我错过了一些小东西。这是我的index.html: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="ImageViewerApp"> <head> <title></title> <script type="text/javascript" src="/scripts/angular.js"></script&g

我觉得我错过了一些小东西。这是我的index.html:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="ImageViewerApp">
<head>
    <title></title>
    <script type="text/javascript" src="/scripts/angular.js"></script>
    <script type="text/javascript" src="/scripts/Controller.js"></script>
</head>
<body ng-controller="ImageViewerCtrl">
    <p>{{Value}}</p>
</body>
</html>
My job.json:

{
  Test: 'Hello, World!'
}
和my Web.config:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json"/>
    </staticContent>
  </system.webServer>
</configuration>
我做错了什么,导致了
错误
而不是调用
成功

编辑:浏览调用堆栈并查看angular.js内部的状态,我发现angular内部的某个地方确实有我期望的用于请求job.json的响应,但在堆栈的后面有一个错误(没有成功传递到我的错误回调),它只是说
无效字符
。我不知道它挂在什么角色上。这并没有帮助我找出哪里出了问题,但也许会帮助我找到答案

{Test: "value"}
以原始格式返回时,它不是有效的JSON。您需要在
周围添加适当的“(引号)

{"Test": "value"}

您是否尝试过将“Test”属性名称小写?也许angular不太喜欢这样。当我将
Test
更改为
Test
或从job.json中删除换行符时,没有任何变化。然而,当我将job.json更改为
{}
时,我确实获得了成功,但只要我将其更改为
{x:1}
它又失败了。你能尝试一下{“Test”:“value”}吗,加上引号。从技术上讲,没有引号它是无效的。这确实有效。有没有办法放宽要求,这样就不需要额外的引号了?
{Test: "value"}
{"Test": "value"}