gpt4 book ai didi

javascript - $.get 一直指向 [object%20Object]

转载 作者:行者123 更新时间:2023-12-03 10:01:01 25 4
gpt4 key购买 nike

我正在使用一个quickbase数据库,我试图让它通过API提取JSON数据,但由于某种原因,每次我尝试获取它时,我在控制台中得到的都是“400(错误请求)” [对象%20Object]"

  <!-- Load handlerbars.js  -->
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.rc.1/handlebars.min.js"></script>
<!-- Load Jquery from CDN for easy DOM manipulations -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>

<!-- Simple handlebars template for a blog post, inside {{variable}} are variables we can afect with JS objects-->
<script id="simple-template" type="text/x-handlebars-template">
<h1>{{title}}</h1>
<p>
{{company}}
</p>
</script>

<script type="text/javascript">

var sgajson = https://sga.quickbase.com/db/<my-db>?apptoken=<my-app-token>&act=API_GenResultsTable&query={8.EX.8}&jsa=1&options=num-1;

//wait for page to load
$(document).ready(function(){
// Extract the text from the template .html() is the jquery helper method for that
var raw_template = $('#simple-template').html();
// Compile that into an handlebars template
var template = Handlebars.compile(raw_template);
// Retrieve the placeHolder where the Posts will be displayed
var placeHolder = $("#main");
// Fetch all record data from server in JSON
$.get(sgajson,function(data,status,xhr){
$.each(data,function(index,element){
// Generate the HTML for each post
var html = template(element);
// Render the posts into the page
placeHolder.append(html);
});
});
});
</script>
</head>

<body>
<!-- Insertion point for handlebars template -->
<div id="main" style="margin-left:100px">
</div>

我已经看到了一些与此相关的事情,但所有这些问题都是通过插件或其他一些我无法有效执行的方法来回答的,所以我希望有一些东西可以解决这个问题,但我没有看到

最佳答案

它读起来就像你实际上通过线路传递的是“[object%20Object]”。如果那是你的实际脚本,我不知道如何

var sgajson = https://sga.quickbase.com/db/bjyi8bgd7?apptoken=bkc8zafhy2b3qc5rdm27d5u2679&act=API_GenResultsTable&query={8.EX.8}&jsa=1&options=num-1;

不是语法错误,值周围没有引号。但无论它如何工作,不知何故你的 sgajson 变量被设置为“[object%20Object]”(在对象上运行 toString() 的结果)而不是你想要的。

关于javascript - $.get 一直指向 [object%20Object],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30600661/

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