$().ready(function() {
// 设置modal 窗体的高度
parent.$('#embed_ifame').css({"height":"500px","width":"600px"});
parent.$('#modal-content').css("width", "650px");
var contextPath = "<%=request.getContextPath()%>";
var category_id = "${standard.productCategory.id}";
initToolbarBootstrapBindings();
$('#editor').wysiwyg({ fileUploadError: showErrorAlert} );
var $select = $("#product_category_select2").select2({
language: "zh-CN",
width: "100%",
theme: "classic",
placeholder: "选择一个分类",
});
// 用ajax的方法获取所有的分类信息
$.ajax({
type: 'GET',
url: contextPath + "/product_categories/category_select2.json",
dataType: 'json',
success: function(data) {
var jsonobj = JSON.stringify(data);
console.debug("jsonobj=="+jsonobj);
for (var i = 0; i < data.length; i++) {
if (data[i].id == category_id) {
$select.append("<option selected = 'selected' value="+ data[i].id +">" + data[i].name + "</option>");
} else {
$select.append("<option value="+data[i].id +">" + data[i].name + "</option>");
}
}
},
complete: function(XMLHttpRequest, textStatus) {
},
error: function(event, jqxhr, settings, thrownError) {
console.debug(event);
console.debug(jqxhr);
console.debug(settings);
console.debug(thrownError);
}
});
})
报400错误

将<script>
var contextPath = "<%=request.getContextPath()%>";
var category_id = "${standard.productCategory.id}";
</script>
放在HTML中错误就会消失