在不关闭弹出窗口的情况下,如何将表单值提交到服务器 [英] without closing the popup window, how to submit the form value to server

查看:61
本文介绍了在不关闭弹出窗口的情况下,如何将表单值提交到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我有一个弹出窗口,它在文本框和textarea中包含一些值. 我需要在不关闭弹出窗口的情况下将值提交到服务器.

Question: I have one popup window it contains some values in textbox and textarea. I need to submit the value to server without closing the popup window.

有没有办法...

预先感谢

推荐答案

是的,在POST中使用Ajax:

Yes, use Ajax with POST:

var url = "get_data.php";
var params = "lorem=ipsum&name=binny";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        alert(http.responseText);
    }
}
http.send(params);

我还要补充一点,您应该能够通过弹出窗口中的表单执行常规POST,而无需关闭它.它只是另一个浏览器窗口...

I would also add that you should be able to do a regular POST via form in the popup without closing it anyway. Its just another browser window...

这篇关于在不关闭弹出窗口的情况下,如何将表单值提交到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆