0
我试图使用Get方法传递Ajax请求。 我已在我的功能请求中添加了一条提醒,以确保链接正常,但我没有提醒!Twig/Ajax通过get方法传递请求
我的代码是:
这是我的看法html.twig:
<a href="#" onclick="request({{ path('mooniki_vote_acteur', { 'id' : 8 }) }});">Je valide !</a>
这是我的javascript代码:
function request(path) {
alert(path);
var xhr = getXMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
alert(xhr.responseText); // Données textuelles récupérées
}
};
xhr.open("GET", path, true);
xhr.send(null);
}
当我把一个字符串参数的要求功能,我有警觉。
谢谢。
这个'a'元素生成的HTML是什么? – cheesemacfly