[英]window.open alternatives to run php file
我有一个javascript,它获取dom值并创建一个指向PHP文件的链接,如下所示:
function extractValue() {
var jobName = document.getElementById('table_jobName').innerText;
var error = document.getElementById('table_error').innerText;
var bugId = document.getElementById('table_bugId').innerText;
var status = document.getElementById('table_status').value;
var comments = document.getElementById('table_comments').innerText;
window.open("http://localhost:8000/save_infra.php?jobName=" + jobName + "&error=" + error +
"&bugId=" + bugId + "&status=" + status + "&comments=" + comments);
}
我实际上不希望打开新窗口并执行php任务。 我只需要将值传递给php。 有没有简单的方法可以做到这一点?
使用异步GET请求(AJAX)。 这不会打开新窗口,并且您的Http请求将被发送。
xhttp.open("GET", Your calculated URL , true);
xhttp.send();
如果您使用的是JQuery,则其中包含的功能可轻松发送http请求和处理响应,请访问http://api.jquery.com/jquery.ajax/
您可以使用ajax功能执行相同的操作。 http://api.jquery.com/jQuery.ajax/这将允许您异步发送数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.