我有一个Javascript文件,它使用ajax加载html文档,但WordPress会更改url。有没有办法设置url以便WordPress不会更改它?
var file = ‘test/file.html’;
WordPress将文件附加到/wp-admin/
并将路径设置为http://localhost/wordpress/wp-admin/test/file.html
当我将文件路径更改为http://localhost/wordpress/wp-content/plugings/test/file.html
, WordPress仍然使用ajaxurl全局变量,并将路径设置为wp-admin
目录代码如下:
return $.ajax({
type: \'get\',
dataType: \'html\',
url: file,
success: function (resp) {
alert(‘Success’);
},
error: function (jqXHR) {
alert(\'Error ‘);
}
});