无刷新自动更新$ _SESSION变量 [英] Automatically update $_SESSION variables without refreshing

查看:184
本文介绍了无刷新自动更新$ _SESSION变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是$ _SESSION变量通过AJAX(他们需要在不刷新页面发送)发送电子邮件,但$ _SESSION变量不会自动更新,所以当它改变时,我需要刷新页面来更新变量

I am using a $_SESSION variable to send emails via AJAX (they need to be sent without refreshing the page), but the $_SESSION variable doesn't automatically update, so when it changes I need to refresh the page to update the variable.

是否有可能无刷新更新$ _SESSION变量?

Is it possible to update the $_SESSION variable without refreshing?

这是在code我使用发送邮件:

This is the code I'm using to send the email:

$(document).ready(function(){
    $("#medicalembassy").validate({
        debug: false,
        rules: {
            name: "required",
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            name: "Please let us know who you are.",
            email: "",
        },
        submitHandler: function(form) {
            // do other stuff for a valid form
            $.post('http://www.example.co.uk/erc/process.php?imei=<?php echo $_SESSION['imei2']; ?>&send_type=2', $("#medicalembassy").serialize(), function(data) {
                $('#results').html(data);
            });
        }
    });
});

因此​​,基本上,如果$ _SESSION变量的变化,我需要这个AJAX电子邮件认识到,无需刷新。

So basically, if the $_SESSION variable changes, I need this AJAX email to recognise that without having to refresh.

感谢您的帮助

推荐答案

一个$ _SESSION变量可以通过在session_start();和清除,如果你使用的session_destroy();。你不能在会话变量的变化多次在同一个文档,但是:文档的AJAX请求被请求的页面每次(AJAX的内页)将会看到的变化,$ _SESSION

A $_SESSION variable is obtained when you run "session_start();" and cleared if you use "session_destroy();". You cannot get the change in the session variables multiple times in the same document, however: the document your AJAX is requesting would see the changes in $_SESSION each time that page was requested (the page inside the AJAX).

这篇关于无刷新自动更新$ _SESSION变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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