简体   繁体   English

在对iframe使用ajax调用时未定义xhttp

[英]xhttp is not defined when using ajax calls into an iframe

Good day all, I'm developing a php page in which there is an iframe, that opens another php page with a checkbox in it, this second page, when the user click on the checkbox, has to make an ajax call to confirm the "click". 美好的一天,我正在开发一个php页面,其中有一个iframe,打开另一个带有复选框的php页面,这个第二页,当用户点击复选框时,必须进行ajax调用以确认“点击”。

so there is pageA.php, with a iframe in it that points to pageB.php, in this one, there is only a form with a checkbox and a javascript (vanilla javascript), that sould call a third page on click. 所以有pageA.php,其中有一个指向pageB.php的iframe,在这一个中,只有一个带有复选框和javascript(vanilla javascript)的表单,可以在点击时调用第三页。

this is the javascript I'm using to send the "click": 这是我用来发送“点击”的javascript:

document.getElementById("checkboxMe").onclick = function() {
    xhttp.open("POST", "pageC.php", true);
    xhttp.send("foo=bar");  
    };

when clicking on the checkbox, this is what I see on the console: 单击复选框时,这是我在控制台上看到的内容:

Uncaught ReferenceError: xhttp is not defined

it never happen something like this, infact I can't find this error easily on google, does anyone has some clues? 它永远不会发生这样的事情,事实上我无法在谷歌上轻易找到这个错误,有没有人有一些线索? maybe is the fact I'm into an iframe? 也许是我进入iframe的事实? how could I solve this issue? 我怎么能解决这个问题?

thanks in advance ppl. 在此先感谢ppl。

xhttp is not a browser built-in. xhttp不是内置的浏览器。 If you don't define it yourself then it won't be defined. 如果您没有自己定义它,那么它将不会被定义。 Frames are irrelevant to that problem. 框架与该问题无关。

Perhaps you intended to first: 也许你打算先:

var xhttp = new XMLHttpRequest();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM