私はJavaスクリプト機能を持っています
function myfunction() {
var url = location.href;
var ajaxRespose;
$.ajax({
type:"GET",
url: url,
cache:false,
dataType: "text",
success: function(response) {
var data = $.parseJSON(response);
ajaxRespose = data;
console.debug("ajaxRespose ==>:"+ajaxRespose);
}
});
console.debug("first ajaxRespose: " +ajaxRespose);
}
return false;
}
私のコンソール(firbug)で私は得る:
first ajaxRespose: undefined
ajaxRespose ==>:[object Object]
私の質問は、「最初の」console.debug の後に ajax 呼び出しが実行される理由です。PS: 関数を簡略化しました (関数は正常に動作しますが、問題は実行順序にあります)。