是否可以傳遞值爲success
函數?傳遞值爲成功函數
function updateData(data_type){
var current_url = "myUrl";
var opc = data_type;
var dataset = [];
$.ajax({
data : {'type': opc},
url : current_url,
type : 'get',
success: function(data){
update(data)
}
});
console.log("update: " + data_type);
}
裏面的success
功能我要訪問我的data_type
變量,我路過參數。
這可能嗎?
是。你可以直接訪問'data_type'。 JavaScript具有詞彙範圍。也許你可以詳細說明你嘗試過什麼,以及你有什麼問題。 –
'data_type'看起來像已經在範圍內。你有沒有嘗試過在你的成功功能中使用它? –