1
我有一個腳本來填充數據庫中的數據,但變量我試圖使用變量selected
似乎沒有被使用。我的意思是Netbeans告訴我這個變量沒有被使用。腳本有問題嗎?JQuery未使用的變量錯誤
function get_child_options(selected)
{
if (typeof selected === 'undefined')
{
var selected = ' ';
}
var parentID = jQuery('#parent').val();
jQuery.ajax(
{
url: '/MyProjectName/admin/parsers/child_categories.php',
type: 'POST',
data:
{
parentID: parentID,
selected: selected
},
success: function(data)
{
jQuery('#child').html(data);
},
error: function()
{
alert("Something went wrong with the child options.")
},
});
}
jQuery('select[name="parent"]').change(get_child_options);
'var selected'在塊範圍之外。在'if'(typeof' – bhantol
selected已經在函數params中定義,在vard''之前移除'var''之前,像@dxcorzo在他的回答中顯示的那樣。 – Shanimal