我试图通过单击索引页面上的菜单(通过母版页调用)通过jQuery AJAX加载网页。页面加载正常。它是购物车类型的东西。页面的各种功能都依赖于javascript。有些脚本工作正常,而其他脚本工作不正常。这是我的ajax代码......
$.ajax({
url: "forms.aspx",
success: function (data) {
$('#formsClick').bind('click', function () {
$("#index1").load('forms.aspx #forms1');
$.getScript('../js/libs/modernizr.js');
//color picker
$.getScript('../js/plugins/colorpicker/bootstrap-colorpicker.js', function () {
var $a = jQuery.noConflict();
$a(document).ready(function () {
var preview = $a('.colorpicker-preview')[0].style;
$a('.colorpicker').colorpicker().on('changeColor', function (ev) {
preview.backgroundColor = ev.color.toHex();
});
});
});
//file upload
$.getScript('../js/plugins/fileupload/bootstrap-fileupload.js');
$.getScript('../js/plugins/inputmask/bootstrap-inputmask.js');
//button switch
$.getScript('../js/plugins/bootstrapSwitch/bootstrapSwitch.js', function () {
var $b = jQuery.noConflict();
});
//tags input
var myStylesLocation1 = "css/plugins/jquery.tagsinput.css";
$('<link rel="stylesheet" type="text/css" href="' + myStylesLocation1 + '" >').appendTo("head");
$.getScript('js/plugins/tagsInput/jquery.tagsinput.min.js', function () {
var $c = jQuery.noConflict();
$c(document).ready(function () {
$c('.tagsinput').tagsInput();
});
});
//wysiwyg
var myStylesLocation = "css/plugins/jquery.jwysiwyg.css";
$('<link rel="stylesheet" type="text/css" href="' + myStylesLocation + '" >').appendTo("head");
$.getScript('../js/plugins/jWYSIWYG/jquery.wysiwyg.js', function () {
var $d = jQuery.noConflict();
$d(document).ready(function () {
$d('.wysiwyg').wysiwyg({
controls: {
bold: { visible: true },
italic: { visible: true },
underline: { visible: true },
strikeThrough: { visible: true },
justifyLeft: { visible: true },
justifyCenter: { visible: true },
justifyRight: { visible: true },
justifyFull: { visible: true },
indent: { visible: true },
outdent: { visible: true },
subscript: { visible: true },
superscript: { visible: true },
undo: { visible: true },
redo: { visible: true },
insertOrderedList: { visible: true },
insertUnorderedList: { visible: true },
insertHorizontalRule: { visible: true },
cut: { visible: true },
copy: { visible: true },
paste: { visible: true }
},
events: {
click: function (event) {
if ($d("#click-inform:checked").length > 0) {
event.preventDefault();
alert("You have clicked jWysiwyg content!");
}
}
}
});
});
});
//editor
var myStylesLocation = "css/plugins/bootstrap-wysihtml5.css";
$('<link rel="stylesheet" type="text/css" href="' + myStylesLocation + '" >').appendTo("head");
$.getScript('../js/plugins/wysihtml5/wysihtml5-0.3.0.js');
$.getScript('../js/plugins/wysihtml5/bootstrap-wysihtml5.js', function () {
$(document).ready(function () {
var $e = jQuery.noConflict();
// Note, we are adding .btn-alt to toolbar template directly in bootstrap-wysihtml5.js for better readability
$e('.wysihtml5').wysihtml5();
});
});
//datepicker
$.getScript('js/plugins/datepicker/bootstrap-datepicker.js', function () {
var $f = jQuery.noConflict();
$f(document).ready(function () {
$f('.datepicker').datepicker({
"autoclose": true
});
});
});
//daterange picker
var myStylesLocations = "css/plugins/daterangepicker.css";
$('<link rel="stylesheet" type="text/css" href="' + myStylesLocations + '" >').appendTo("head");
$.getScript('js/plugins/dateRangePicker/date.js');
$.getScript('js/plugins/dateRangePicker/daterangepicker.js', function () {
var $g = jQuery.noConflict();
$g(document).ready(function () {
$g('#demoDaterangePicker').daterangepicker();
});
});
//timepicker
$.getScript('js/plugins/bootstrapTimePicker/bootstrap-timepicker.min.js', function () {
var $h = jQuery.noConflict();
$h(document).ready(function () {
$h('#demoTimepicker').timepicker({
minuteStep: 5,
showInputs: false,
disableFocus: true
});
});
});
//validation
$.getScript('js/plugins/bootstrapValidation/jqBootstrapValidation.min.js', function () {
var $i = jQuery.noConflict();
$i(document).ready(function () {
$("#demoValidation input").jqBootstrapValidation({
submitSuccess: function ($form, event) {
event.preventDefault();
}
});
});
});
$.getScript('js/plugins/prettyCheckable/prettyCheckable.js', function () {
var $j = jQuery.noConflict();
$j(document).ready(function () {
$j('.custom-checkbox input, .custom-radio input').prettyCheckable();
});
});
});
}
});
答案 0 :(得分:0)
相对网址是否正确?
我问,因为我看到一些getScript就像这个$.getScript('../js/etc.'
,其他人就像这样:$.getScript('js/etc.'
。
我不知道这是不是问题,但可能是一个问题。
无论如何,如果你在“控制台”标签中使用Chrome开发者工具(ctrl + shift + i),你应该能够理解这个问题。