好吧,这个问题已经足够解释了,可以完成吗。
我试图做的是从弹出窗口中获取数据,然后我想将检索到的内容发送到php控制器进行处理。
但我不想使用jquery库,因为它给我带来了冲突
更新
window.onbeforeunload = confirmExit;
function confirmExit()
{
var a = document.getElementsByTagName("div");
for (i = 0; i < a.length; i++) {
if(a[i].className == 'Ymacs-frame-content'){
var b = a[i].getElementsByTagName("div").innerHTML;
//alert(b);
}
}
//Ajax should be here
window.onbeforeunload = reloadOpener;
if (top.opener && !top.opener.closed) {
try {
opener.location.reload(1);
}
catch(e) { }
window.close();
}
}
window.ununload=function() {
reloadOpener();
}
您可以使用无jquery的AJAX:
var a = new XMLHttpRequest();
a.open("GET","myscript.php?var=foo&othervar=bar",true);
a.onreadystatechange = function() {
if( this.readyState == 4) {
if( this.status == 200) {
// data sent successfully
// response is in this.responseText
}
else alert("HTTP error "+this.status);
}
};
a.send();
或者,您可以创建一个iframe
标记并将其指向右侧页面。如果需要,您甚至可以创建一个表单并将其发布到框架中。
您可以在不使用jQuery的情况下在javascript中执行此操作,因为这是jQuery在后台所做的全部工作。不过,你需要看看IE与其他浏览器相比的不同方式。
是的,XMLHttpRequest,但您需要考虑浏览器中的差异,jQuery就是这样做的。
我刚刚经历了这个。使用Javascript将信息传递给PHP的唯一方法是使用XMLHttpRequest,或者至少如果有其他方法我没有找到它的话。这与PHP在服务器端呈现的事实有关,Javascript在提供给客户端之后才会执行。。。除非您使用XHR,它是…AJAX.