Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.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
javascript中没有来自数组的json_Javascript_Jquery_Html_Json - Fatal编程技术网

javascript中没有来自数组的json

javascript中没有来自数组的json,javascript,jquery,html,json,Javascript,Jquery,Html,Json,下面的代码旨在从arraylist返回json对象,但它没有显示警报。 没有js错误 <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script&

下面的代码旨在从arraylist返回json对象,但它没有显示警报。 没有js错误

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="json.js" />
<script type="text/javascript" src="json2.js" />
<script type="text/javascript">
var my_info= {};
my_info["john"]="1a";
my_info["joseph"]="2b";
my_info["helen"]="3c";

var val = JSON.stringify(my_info);

alert(val);
</script>
</head>
<body>

</body>
</html>

var my_info={};
我的信息[“约翰”]=“1a”;
我的信息[“约瑟夫”]=“2b”;
我的信息[“海伦”]=“3c”;
var val=JSON.stringify(我的信息);
警报(val);

脚本标记不允许自动关闭(
)。您必须改用

有关更多信息,请参阅

您的代码变成:

<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script type="text/javascript" src="json.js"></script> <!-- Here -->
        <script type="text/javascript" src="json2.js"></script> <!-- And here -->
        <script type="text/javascript">
            var my_info= {};
            my_info["john"]="1a";
            my_info["joseph"]="2b";
            my_info["helen"]="3c";

            var val = JSON.stringify(my_info);

            alert(val);
        </script>
    </head>
    <body>
    </body>
</html>

var my_info={};
我的信息[“约翰”]=“1a”;
我的信息[“约瑟夫”]=“2b”;
我的信息[“海伦”]=“3c”;
var val=JSON.stringify(我的信息);
警报(val);

(忽略警告)

删除包含json.js和json2.js的链接。警报不会显示它们是否不可用。@sza这是错误的。404错误不会阻止其他js代码的运行。答案是。