我有2个URL,我尝试使用jQuery的.get功能,第一个链接完美运行,但第二个不会将数据附加到div。jQuery - .get适用于1个URL,但不适用于另一个
//Locate the input box
var URL = $('#download');
//When button gets pressed
function downloadURL(){
//Get the URL from the input box
var downloadURL = URL.val();
//Get the contents of the JSON on the website linked
$.get(downloadURL,
\t //add it to the output div
function(data){
$("#output").append(data)
}
);
//Tell me that it has actually accepted the URL
alert(downloadURL);
}
<p> <input type="text" name="download" id="download" placeholder="Download URL"></p>
<button onclick="downloadURL()">Test</button>
<div id="output"></div>
的2个网址,我试图为:https://raw.githubusercontent.com/TemporalReality/modpacks/master/packs/ingenuity.json和http://widget.mcf.li/mc-mods/minecraft/224791-blood-magic.json
任何想法,为什么它为一个URL,而不是其他?或者更好的方法来做到这一点?
上面我说的那个人是正确的。解决这个问题的唯一方法是使用类似于php或服务器端脚本的方式从服务器请求数据。 – Chris