Javascript 如何通过AJAX-Elgg调用HTML?
我试图通过AJAX调用Elgg中的视图,但是在这里Elgg使用requirejs之后,没有任何效果。试试这个:Javascript 如何通过AJAX-Elgg调用HTML?,javascript,php,html,ajax,elgg,Javascript,Php,Html,Ajax,Elgg,我试图通过AJAX调用Elgg中的视图,但是在这里Elgg使用requirejs之后,没有任何效果。试试这个: requirejs(["elgg/Ajax"], function(Ajax) { var ajax = new Ajax(); //rest of your code!! }); 否则,请使用本机JS var xhr = new XMLHttpRequest(); xhr.open('GET', encodeURI('albums/inline_full_image
requirejs(["elgg/Ajax"], function(Ajax) {
var ajax = new Ajax();
//rest of your code!!
});
否则,请使用本机JS
var xhr = new XMLHttpRequest();
xhr.open('GET', encodeURI('albums/inline_full_image_view'));
xhr.onload = function() {
if (xhr.status === 200) {
alert('User\'s name is ' + xhr.responseText);
}
else {
alert('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();
您是否正在尝试使用ajax在脚本标记中添加数据?谢谢您的回复@Iceman。现在我只想通过AJAX调用视图。视图是一个PHP文件,它回显一个简单的字符串。我在问题中添加了它作为更新。现在,我对这些数据不太感兴趣。我在原生JS中发布了一个解决方案。这行吗?如果不行,我就删除答案!如果soln.worked mark被接受,请。我正在尝试@Iceman。谢谢你的回复。
requirejs(["elgg/Ajax"], function(Ajax) {
var ajax = new Ajax();
//rest of your code!!
});
var xhr = new XMLHttpRequest();
xhr.open('GET', encodeURI('albums/inline_full_image_view'));
xhr.onload = function() {
if (xhr.status === 200) {
alert('User\'s name is ' + xhr.responseText);
}
else {
alert('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();