康卡特不工作

时间:2014-04-27 21:17:32

标签: javascript html

我试图在javascript中连接字符串。它在本地工作但是当我将它更新到html主机时,它不起作用。代码中的其他所有内容都可以使用:

<!DOCTYPE html>
<html>
    <head>
        <script type = "text/javascript" src = "http://mbostock.github.com/d3/d3.js">
        </script>
        <script src = "//www.parsecdn.com/js/parse-1.2.18.min.js"></script>
        <script src = "http://d3js.org/d3.v3.min.js"></script>
    </head>
    <meta charset="utf-8">
    <body>
        <script type = "text/javascript">
            Parse.initialize("", "");
            var json = '{\n\t"nodes":[\n';
            var DeedsClass = Parse.Object.extend("Deeds");
            var query = new Parse.Query(DeedsClass);
            var json = '{\n\t"nodes":[\n';
            query.find( {
                success: function (results) {
                    var i = results.length;
                    var j = 0;
                    var m = j + 1;
                    for (j = 0; j < i; j++) {
                        m = m + 1;
                        json = json.concat('\t\t{"name":"Deed' + j + '", "group":' + m + '}');
                        if(m == i) json = json.concat('\n\t],');
                        else json = json.concat(',\n');
                    }
                }
            });
            document.write(json + "<br>");
        </script>
</html>

我在document.write中获取此输出:{&#34; nodes&#34;:[在服务器上。 但是,我在我的本地机器上得到了这个:

  

{&#34; nodes&#34;:[{&#34; name&#34;:&#34; Deed1&#34;,&#34; group&#34;:1},{&#34; name&#34;:&#34; Deed2&#34;,&#34; group&#34;:2},   {&#34; name&#34;:&#34; Deed3&#34;,&#34; group&#34;:3},{&#34; name&#34;:&#34; Deed4&#34;, &#34;组&#34;:4},   {&#34; name&#34;:&#34; Deed5&#34;,&#34; group&#34;:5},{&#34; name&#34;:&#34; Deed6&#34;, &#34;组&#34;:6},   {&#34; name&#34;:&#34; Deed7&#34;,&#34; group&#34;:7},{&#34; name&#34;:&#34; Deed8&#34;, &#34;组&#34;:8},   {&#34; name&#34;:&#34; Deed9&#34;,&#34; group&#34;:9},{&#34; name&#34;:&#34; Deed0&#34;, &#34;组&#34;:0},   {&#34; name&#34;:&#34; Deed1&#34;,&#34; group&#34;:1},{&#34; name&#34;:&#34; Deed2&#34;, &#34;组&#34;:2},   {&#34; name&#34;:&#34; Deed3&#34;,&#34; group&#34;:3},{&#34; name&#34;:&#34; Deed4&#34;, &#34;组&#34;:4},   {&#34; name&#34;:&#34; Deed5&#34;,&#34; group&#34;:5},{&#34; name&#34;:&#34; Deed6&#34;, &#34;组&#34;:6},   {&#34; name&#34;:&#34; Deed7&#34;,&#34; group&#34;:7},{&#34; name&#34;:&#34; Deed8&#34;, &#34;组&#34;:8},   {&#34; name&#34;:&#34; Deed9&#34;,&#34; group&#34;:9},{&#34; name&#34;:&#34; Deed0&#34;, &#34;组&#34;:0},

预计后者。我知道这似乎很简单,但它不起作用。有什么想法吗?

0 个答案:

没有答案