我已经定义了 JavaScript 方法,当我调用该方法时,我得到以下异常
Uncaught ReferenceError: getProvidersList is not defined.
这是我定义的 JavaScript 方法:
function getProvidersList(categoryIndex){
var index = $('#'+categoryIndex).val();
console.log("index"+index);
var url ='${pageContext.request.contextPath}/rechargewallet/rechargeWalletGetSubCategoryRequest.htm';
$.ajax({
type: "GET",
url: url,
data: "categoryIndex=" + categoryIndex ,
success: function(response){
if('null' != response && (typeof response != 'undefined')){
var subCategoriesList = '<select name=subCategoriesList id=subCategoriesList>';
for (var i = 0; i < response.length; i++) {
var nameOfTheProvider = response[i].nameOfTheProvider;
subCategoriesList = subCategoriesList + '<option value="'+nameOfTheProvider'" label="'+nameOfTheProvider'"></option>';
}
$('#subCategoriesListselectBlock').html(subCategoriesList);
$('#subCategoriesList').show();
}else{
$('#categoriesList').show();
$('#subCategoriesList').hide();
}
}
});
}
这就是我调用上述方法的方式:
<input type="radio" name="categoriesList" id="${categoryName}" value="${category.index}" onclick="getProvidersList(this.id)" />
加载页面时我也收到此异常:
uncaught SyntaxError: Unexpected token +
在这一行:subCategoriesList = subCategoriesList + '<option value="'+nameOfTheProvider'" label="'+nameOfTheProvider'"></option>';
我很困惑,通常当方法没有定义和调用时会抛出这种异常,但我的情况,我已经定义了方法并调用了相同的方法,但是为什么我会得到这种undefined
异常?
请告诉我如何解决这个问题..
谢谢。