Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何通过AJAX-Elgg调用HTML?_Javascript_Php_Html_Ajax_Elgg - Fatal编程技术网

Javascript 如何通过AJAX-Elgg调用HTML?

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

我试图通过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_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();