[英]window.open alternatives to run php file
I have a javascript where it gets the dom values and creates a link which points to a PHP file as below: 我有一个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);
}
I don't actually want a new window to open and do the php task. 我实际上不希望打开新窗口并执行php任务。 I just need to pass on the value to php.
我只需要将值传递给php。 Is there a simple way to do this?
有没有简单的方法可以做到这一点?
Use an asynchronous GET request (AJAX). 使用异步GET请求(AJAX)。 this will not open a new window and your Http request will be sent.
这不会打开新窗口,并且您的Http请求将被发送。
xhttp.open("GET", Your calculated URL , true);
xhttp.send();
If you are using JQuery, there are functions in it to easily send http requests and handle the response, have a look at http://api.jquery.com/jquery.ajax/ 如果您使用的是JQuery,则其中包含的功能可轻松发送http请求和处理响应,请访问http://api.jquery.com/jquery.ajax/
You can use the ajax feature to do the same. 您可以使用ajax功能执行相同的操作。 http://api.jquery.com/jQuery.ajax/ This is will allow you to send the data Asynchronously
http://api.jquery.com/jQuery.ajax/这将允许您异步发送数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.