这是我之前提到过的一些重新发布的内容。但为了清晰起见,我添加了代码的小提琴 - JSONP - JSFiddle
var sTerm = "summerstyle";
fnMakeCallback();
function fnMakeCallback(){
$.ajax({
type: 'POST',
url:"http://54.252.155.222/~forever/index.php/hype_engine_controller/load_widget_jsonp/%23"+sTerm+"?callback=jsonpCallback",
dataType:"jsonp",
jsonp:"callback",
async: false,
crossdomain: true,
jsonpCallback:"jsonpCallback",
success: function(data) {
$("#hype_engine").html(data.html);
}
});
}
function jsonpCallback(data){
}
我似乎在data.html中获取html - 将其附加到div。但data.head包含一堆样式标记。我需要这些文件来处理我在data.html中加载的HTML。 (JS / jQuery插件等)任何人都可以帮助我理解如何执行这些脚本文件,以便在我通过上面的代码提取HTML时它们可用吗?
它似乎没有加载文件,因为我得到了很多“Uncaught TypeError:Object [object Object]没有方法'carouFredSel'”和类似。它还为我提供了跨域请求错误 - 在上面的JSLINT上可见 -
XMLHttpRequest cannot load http://54.252.155.222/~forever/assets/js/lib/jquery-ui-1.10.1.custom.js. Origin http://fiddle.jshell.net is not allowed by Access-Control-Allow-Origin.
- 让我觉得用源代码加载脚本并不是那么简单
我做错了什么?!
编辑: 我不再将脚本加载到HEAD中,而只是将它们加载到内联中 - 这不是很好的做法我承认但我只是想让它先工作 - 我正在通过codeigniter加载,但标题视图如下 -
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/jquery-ui-1.10.1.custom.js'></script>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/bootstrap.min.js'></script>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/main.js'></script>
<script type='text/javascript' src='http://api.filepicker.io/v1/filepicker.js'></script>
<link href='http://fonts.googleapis.com/css?family=Henny+Penny|Gloria+Hallelujah|Nothing+You+Could+Do|Over+the+Rainbow' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='<?= base_url(); ?>assets/css/bootstrap.min.css'/>
<link rel='stylesheet' href='<?= base_url(); ?>assets/css/internal/main.css'/>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/jquery.carouFredSel-6.2.1-packed.js'></script>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/helper-plugins/jquery.mousewheel.min.js'></script>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/helper-plugins/jquery.touchSwipe.min.js'></script>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/helper-plugins/jquery.transit.min.js'></script>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/helper-plugins/jquery.ba-throttle-debounce.min.js'></script>
<link rel='stylesheet' href='<?= base_url(); ?>assets/js/lib/fancybox/jquery.fancybox.css?v=2.1.4' type='text/css' media='screen' />
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/fancybox/jquery.fancybox.pack.js?v=2.1.4'></script>
<link rel='stylesheet' href='<?= base_url(); ?>assets/js/lib/fancybox/helpers/jquery.fancybox-buttons.css?v=1.0.5' type='text/css' media='screen' />
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/fancybox/helpers/jquery.fancybox-buttons.js?v=1.0.5'></script>
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/fancybox/helpers/jquery.fancybox-media.js?v=1.0.5'></script>
<link rel='stylesheet' href='<?= base_url(); ?>assets/js/lib/fancybox/helpers/jquery.fancybox-thumbs.css?v=1.0.7' type='text/css' media='screen' />
<script type='text/javascript' src='<?= base_url(); ?>assets/js/lib/fancybox/helpers/jquery.fancybox-thumbs.js?v=1.0.7'></script>