0

Okay, I'm trying to do this a mission form, once visitor presses begin, it pops up a new tab with a registration form ( not my actual website ) after they register, this second website will send something to let me know this visitor completed his registration,

okay but this is not the thing, i want to receive registration result live from the main webpage which the user started the mission from, how to do this without having to refresh specific page several times to check current status, i want to receive it live once registration is completed from the main page

using jquery, javascript or php or just any possibility to do this

4

4 回答 4

1

在第一页,您可以使用 $.ajax (http://api.jquery.com/jQuery.ajax/) 将注册信息发布到数据库,然后在第二页检索它(也使用 $.ajax )。问题是第二页如何知道用户是否在第一页完成了他们的业务(由“window.opener”方法标识)?为此,您可以每隔一秒执行一次 setTimeout() 以查看注册是否已完成。如果是,则从数据库中检索信息。

虽然使用 $.ajax 可能过于依赖用户的互联网连接,我个人觉得它很慢。一种更快的方法是使用 cookie 来检查用户是否已完成注册。

还有一种相对较新的 HTML5 方法,称为“本地存储”,它充当客户端数据库(与 cookie 不同,它可以支持大量数据,您可以将整个注册表单存储在上面)。它也比轮询关系数据库相对快。

于 2012-06-15T17:28:51.120 回答
0

You could do it like this:

  1. Listen for the message from the second website
  2. Make the mission form ask your service (every second or what suits your need) with ajax
  3. When the message has arrived, return "true". If it hasn't return "false"
  4. Perform your actions on the client side when the client recieves a "true".
于 2012-06-15T17:11:05.997 回答
0

You'll still need to poll home to check if work is done, because server can't initiate connection to client. To prevent page refresh, use AJAX for polling.

于 2012-06-15T17:11:06.477 回答
0

使用 jQuery ajax将注册数据发送到服务器,并在事务(将用户保存到数据库)完成后返回一些响应。在回调函数中抓取它并做进一步的事情(显示消息/重新加载页面的某些部分等......)

所以像这样将您的注册数据发送到服务器页面

$(function(){

   $("form").submit(e){
    e.preventDefault();
       $.post("yourRegistrationProcess.php",$("form").serialize(),function(data){
          //You have the response from server in data variable.
          // Do whatever you want next with that.          
       });
   });

});

假设您yourRegistrationProcess.php在将用户注册数据保存到表后从(回显“已保存”;等等)发回一些响应。

于 2012-06-15T17:39:24.727 回答