无法使用 JS 处理提要
Unable to process feed with JS
我有 link 到下面引用的提要,我想仅使用 JavaScript 显示 HTML 文件中它的元素的数据。我试图先在控制台中进行此操作,但出现错误 Invalid JSON format
知道如何解决这个问题以及如何让它发挥作用吗?提前谢谢你。
$(document).ready(function() {
var link = 'https://neon.epson-europe.com/frame/interfaces/newsroomcustom.php?json={"area":["blogarticle"],"tags":["Kids%20corner"],"limit":3,"offset":0,"language":"en","country":"GB","action":"getList","jsonp":"jsonp"}';
$.ajax({
dataType: 'jsonp',
data: 'id=10',
url: link + ";callback=?",
success: function(data) {
console.log(data);
},
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TestTest</title>
<script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
</head>
<body>
<h1>article title should be here</h1>
<p> subtitle should be here </p>
<image src=" link to the image should be here ">
<p>date should be here</p>
</body>
我做了一些更改以提高您的 JS 的可读性,无论如何,使它一切正常的是这个 属性 我添加了:jsonpCallback: 'jsonp'
。这是修改后的完整代码:
$(document).ready(function() {
var link = 'https://neon.epson-europe.com/frame/interfaces/newsroomcustom.php';
$.ajax({
dataType: 'jsonp',
jsonpCallback: 'jsonp',
data: 'json={"area":["blogarticle"],"tags":["Kids%20corner"],"limit":3,"offset":0,"language":"en","country":"GB","action":"getList","jsonp":"jsonp"}&id=10',
url: link + ";callback=?",
success: function(data) {
console.log(data);
},
});
});
测试并告诉我是否适合你。
我有 link 到下面引用的提要,我想仅使用 JavaScript 显示 HTML 文件中它的元素的数据。我试图先在控制台中进行此操作,但出现错误 Invalid JSON format
知道如何解决这个问题以及如何让它发挥作用吗?提前谢谢你。
$(document).ready(function() {
var link = 'https://neon.epson-europe.com/frame/interfaces/newsroomcustom.php?json={"area":["blogarticle"],"tags":["Kids%20corner"],"limit":3,"offset":0,"language":"en","country":"GB","action":"getList","jsonp":"jsonp"}';
$.ajax({
dataType: 'jsonp',
data: 'id=10',
url: link + ";callback=?",
success: function(data) {
console.log(data);
},
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TestTest</title>
<script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
</head>
<body>
<h1>article title should be here</h1>
<p> subtitle should be here </p>
<image src=" link to the image should be here ">
<p>date should be here</p>
</body>
我做了一些更改以提高您的 JS 的可读性,无论如何,使它一切正常的是这个 属性 我添加了:jsonpCallback: 'jsonp'
。这是修改后的完整代码:
$(document).ready(function() {
var link = 'https://neon.epson-europe.com/frame/interfaces/newsroomcustom.php';
$.ajax({
dataType: 'jsonp',
jsonpCallback: 'jsonp',
data: 'json={"area":["blogarticle"],"tags":["Kids%20corner"],"limit":3,"offset":0,"language":"en","country":"GB","action":"getList","jsonp":"jsonp"}&id=10',
url: link + ";callback=?",
success: function(data) {
console.log(data);
},
});
});
测试并告诉我是否适合你。