jQuery Ajax 関数を使用して、WordPress テーマにいくつかのデモ データをインストールします。以下のこのスクリプトは、私が取り組んだ以前のテーマで機能しましたが、何らかの理由でエラーが発生しています
Uncaught TypeError: Cannot call method 'hasOwnProperty' of null
これが私が使用しているスクリプトです
/* Install Dummy Data */
function install_dummy() {
$('#install_dummy').click(function(){
$.ajax({
type: "post",
url: $AjaxUrl,
dataType: 'json',
data: {action: "install_dummy", _ajax_nonce: $ajaxNonce},
beforeSend: function() {
$(".install_dummy_result").html('');
$(".install_dummy_loading").css({display:""});
$(".install_dummy_result").html("Importing dummy content...<br /> Please wait, this process can take up to a few minutes.");
},
success: function(response){
var dummy_result = $(".install_dummy_result");
if(typeof response != 'undefined')
{
if(response.hasOwnProperty('status'))
{
switch(response.status)
{
case 'success':
dummy_result.html('Dummy Data import was successfully completed');
break;
case 'error':
dummy_result.html('<span style="color:#f00">'+response.data+'</span>');
break;
default:
break;
}
}
}
$(".install_dummy_loading").css({display:"none"});
}
});
return false;
});
}
install_dummy();
どんな助けでも大歓迎です。