未捕获的ReferenceError:未定义Parse

时间:2015-01-03 14:43:10

标签: javascript url url-rewriting parse-platform google-drive-api

尝试执行解析时,我意外地通过调试器收到了以下错误。

Uncaught ReferenceError: Parse is not defined 

我很确定它定义得很好,因此不确定错误源自何处。

基本上,这里发生的是,使用google url缩短将长网址转换为短网址,然后解析抓取缩短的网址并存储它。

<html>
<head>
</head>
<script type="text/javascript">
function makeShort() 
{
   var longUrl=document.getElementById("longurl").value;
    var request = gapi.client.urlshortener.url.insert({
    'resource': {
      'longUrl': longUrl
    }
    });
    request.execute(function(response) 
    {

        if(response.id != null)
        {
            str ="<a href='"+response.id+"'>"+response.id+"</a>";
            document.getElementById("output").innerHTML = str;

              Parse.initialize("ID", "ID");
           var PDFUpload = new Parse.Object("Scan");


     PDFUpload.set("PDFDocument", str);

    PDFUpload.save(null, 
     {
        success: function(uploadResult) {
          // Execute any logic that should take place after the object is saved.

        },
        error: function(uploadResult, error) {
          // Execute any logic that should take place if the save fails.
          // error is a Parse.Error with an error code and description.
          alert('Failed to create new object, with error code: ' + error.description);
        }
     });

        }


        else
        {
            alert("error: creating short url");
        }

    });
 }


function load()
{
    gapi.client.setApiKey('ID'); //get your ownn Browser API KEY
    gapi.client.load('urlshortener', 'v1',function(){});

}
window.onload = load;

</script>
<script src="https://apis.google.com/js/client.js"> </script>

<body>

URL: <input type="text" id="longurl" name="url" value="yahoo.com" /> <br/>
<input type="button" value="Create Short" onclick="makeShort();" /> <br/> <br/>


<div id="output"></div>


</body>
</html>

特别是,下面是对话发生,我试图存储要解析的URL:

        if(response.id != null)
        {
            str ="<a href='"+response.id+"'>"+response.id+"</a>";
            document.getElementById("output").innerHTML = str;

              Parse.initialize("ID", "ID");
           var PDFUpload = new Parse.Object("Scan");


     PDFUpload.set("PDFDocument", str);

    PDFUpload.save(null, 
     {
        success: function(uploadResult) {
          // Execute any logic that should take place after the object is saved.

        },
        error: function(uploadResult, error) {
          // Execute any logic that should take place if the save fails.
          // error is a Parse.Error with an error code and description.
          alert('Failed to create new object, with error code: ' + error.description);
        }
     });

        }

1 个答案:

答案 0 :(得分:2)

也许你在另一个文件中有这个,但你的代码在哪里引用Parse http://www.parsecdn.com/js/parse-1.3.5.min.js

也许你错过了那个,这就是你得到错误的原因。