gpt4 book ai didi

javascript - Uncaught ReferenceError : Parse is not defined

转载 作者:行者123 更新时间:2023-11-30 17:07:12 25 4
gpt4 key购买 nike

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

Uncaught ReferenceError: Parse is not defined 

我很确定它的定义很好,所以不确定错误的来源。

本质上,这里发生的是使用 google url shorten 将长 url 转换为短 url,然后解析获取缩短的 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);
}
});

}

最佳答案

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

也许您遗漏了这一点,这就是您收到错误的原因。

关于javascript - Uncaught ReferenceError : Parse is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27756009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com