繁体   English   中英

如何从电子桌面应用程序向php网站发送和接收数据?

[英]How to send and receive data from electron desktop app to a php website?

我是 nodejs 和 php 开发人员的实习生。我想通过验证 php 网站数据库中的 macaddress 来检查我的桌面应用程序可用性。我尝试使用href="xyz.com?name=abc"从应用程序发送数据。 它在桌面应用程序中加载此页面,但我无法使用某些返回值返回应用程序的 html 页面。可以使用window.history.back()返回应用程序 html 页面,但无法检索任何值,其他函数在网站directory.like window.location.href()搜索页面。如directory.like window.location.href()
我也在应用程序的html页面中尝试了ajax,它也不起作用..

电子应用程序中的 HTML 页面..

<body>
<h1>Hello World!</h1>
<p id="ptext"></p>
<form>
  <input type="hidden" name="value" value="abc">
  <button id="start">start</button>
</form>

<script type="text/javascript"> console.log('hello');
  // document.getElementById('ptext').innerHtml =  window.location.search();
  $(document).ready(function{
    console.log('started document');
    $('#start').click(function{
      var formData = $(form).serialize();
      alert(formdata);
      $.ajax({
        type: 'GET',
        data: formData,
        url: "http://localhost/newproject/index.php",
        success: function (data, status, xhr) {
          $('#ptext').append(data)
        },
         error: function (jqXhr, textStatus, errorMessage) {
            $('#ptext').append('Error: ' + errorMessage)
          }
      });
    });
  });
</script>

PHP网站页面

<?php 
$val = $_GET['value'];
echo "\n".$val;
if($val=='abc')
    {
?>
<!-- <script type="text/javascript">window.history.back();</script>
 --><?php 
        echo "\nright value";
    }
else
    {
        echo "\nwrong value";
    }
// echo "\n".$_SERVER['HTTP_REFERER']; -------> does Not have any value , undefined
// header("location:index.html?result==right/wrong") -----> it search this page in website directory
 ?>

现在,我如何将一些数据返回给 nodejs 电子应用程序。
这对我的项目会有很大帮助。
谢谢大家看我在这个网站上的第一个问题。

暂无
暂无

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

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