php 鼠标小手,鼠标移动至少一次时创建PHP会话(Create PHP session when mouse moved at least once)...
鼠標(biāo)移動(dòng)至少一次時(shí)創(chuàng)建PHP會(huì)話(Create PHP session when mouse moved at least once)
我想在鼠標(biāo)移動(dòng)至少一次時(shí)創(chuàng)建php會(huì)話,如果鼠標(biāo)繼續(xù)移動(dòng)則不需要做任何事情
我正在使用此代碼,但它沒(méi)有解決要求
jQuery(document).ready(function()
{
$(document).mousemove(function(e)
{
$('#status').html(e.pageX);
$('#status1').html(e.pageY);
$.ajax({
type: 'POST',
url: 'second.php',
data: {
'x': '10',
'y': '20'
},
success: function(msg){
//what you want after request
}
});
});
});
I want to create php session when mouse is moved at least once then no need to do anything if mouse keeps moving
I am using this code but its not solving the requirement
jQuery(document).ready(function()
{
$(document).mousemove(function(e)
{
$('#status').html(e.pageX);
$('#status1').html(e.pageY);
$.ajax({
type: 'POST',
url: 'second.php',
data: {
'x': '10',
'y': '20'
},
success: function(msg){
//what you want after request
}
});
});
});
原文:https://stackoverflow.com/questions/47845256
更新時(shí)間:2020-01-28 06:34
最滿意答案
PHP代碼應(yīng)該是這樣的:
session_start();
if (!isset($_SESSION['mouseMoved'])
$_SESSION['mouseMoved'] = "whatever you want";
此外,您應(yīng)該在JS中設(shè)置一些變量,以便僅將請(qǐng)求發(fā)送到服務(wù)器一次。
The PHP code should be something like this:
session_start();
if (!isset($_SESSION['mouseMoved'])
$_SESSION['mouseMoved'] = "whatever you want";
Also, you should set some variable in JS so that the request is only sent to the server once.
2017-12-17
相關(guān)問(wèn)答
要回顯會(huì)話,您需要調(diào)用session-variable,而不是與session-variable同名的常規(guī)變量。 所以你的回聲是: echo $_SESSION["AgreeNum"];
此外,如果您在寫入會(huì)話時(shí)遇到問(wèn)題,則可能必須在向會(huì)話寫入任何內(nèi)容之前調(diào)用session_start() 。 To echo your session you will need to call the session-variable, not a regular variable with the same
...
您已經(jīng)在第2-3行發(fā)送
后嘗試發(fā)送Location標(biāo)題。 你不能這樣做。 必須在發(fā)送任何輸出之前發(fā)送標(biāo)頭。 老實(shí)說(shuō),我不知道你的代碼如何在你的本地服務(wù)器上工作。 You are trying to send a Location header after you've already sent on lines 2-3. You can't do that. Headers must be sent before any output is sent...
你有沒(méi)有在XAML中搞定你的活動(dòng)? 例如
//Your Page
Have you hooked your event up in XAML? For Example
//Your Page
檢查包含的文件/代碼結(jié)構(gòu)..導(dǎo)致此錯(cuò)誤的常見(jiàn)原因是: session_start();
/* Random Code here /*
session_start();
只是session_start();的重復(fù)行session_start(); 因此,我建議查看您收到此錯(cuò)誤消息的所包含文件/主頁(yè),并檢查多個(gè)session_start(); Check over your included files/code structure.. A usual cause for this erro
...
首先,并非所有版本的窗口都會(huì)在鼠標(biāo)移動(dòng)時(shí)更改滾動(dòng)條的顏色。 如果您發(fā)現(xiàn)在Windows XP中找不到此功能。 現(xiàn)在很奇怪你為什么要改變滾動(dòng)條的顏色我不明白。 但是你想要的 將鼠標(biāo)移到滾動(dòng)上時(shí)會(huì)觸發(fā)的消息是什么? 當(dāng)鼠標(biāo)在滾動(dòng)條上移動(dòng)時(shí)調(diào)用其WM_NCMOUSEMOVE消息,因?yàn)闈L動(dòng)條也是非客戶區(qū)。 有關(guān)此問(wèn)題的更多信息,您可以參考此鏈接, MFC MDI問(wèn)題:檢測(cè)鼠標(biāo)移動(dòng)滾動(dòng)條 First of all not all version of window changes the color of
...
根據(jù)此主題,此問(wèn)題似乎是Chrome錯(cuò)誤: 圖片在懸停時(shí)移動(dòng) - 鍍鉻不透明度問(wèn)題 ,我認(rèn)為您應(yīng)該設(shè)置位置:相對(duì)于內(nèi)部img解決問(wèn)題 This issue appears to be a Chrome bug according to this topic: image moves on hover - chrome opacity issue and I think you should setting position:relative to inner img solves the prob
...
你看到所有的mouseMoved方法都被調(diào)用嗎? 這是寫的方式,mouseMoved方法是PaintSurface的成員,但PaintSurface不是MouseMotionListener。 實(shí)現(xiàn)'MouseMotionListener'將強(qiáng)制它實(shí)現(xiàn)mouseMoved和mouseDragged 。 完成之后,您可以將自己的PaintSurface添加為自己作為MouseMotionListener 。 或者,您可以在已經(jīng)定義的MouseMotionAdapter匿名類中移動(dòng)mouseMoved
...
你確定你的瀏覽器正在接受它應(yīng)該的cookies嗎? 為了確保你嘗試在不同的瀏覽器,然后通常的 are you sure your browser is accepting cookies like it should be ? To make sure you try in a different browser then your usual one
PHP代碼應(yīng)該是這樣的: session_start();
if (!isset($_SESSION['mouseMoved'])
$_SESSION['mouseMoved'] = "whatever you want";
此外,您應(yīng)該在JS中設(shè)置一些變量,以便僅將請(qǐng)求發(fā)送到服務(wù)器一次。 更新:一個(gè)工作的jsfiddle https://jsfiddle.net/bqh0yrtp/ The PHP code should be something like this: session_
...
也許GetLastInputInfo就是你在這里需要的MSDN 。 例如,要獲取自上次鼠標(biāo)移動(dòng)或按鍵操作后經(jīng)過(guò)的毫秒數(shù),您可能具有如下函數(shù): DWORD GetIdleTime()
{
LASTINPUTINFO pInput;
pInput.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&pInput))
{
// report error, etc.
}
...
總結(jié)
以上是生活随笔為你收集整理的php 鼠标小手,鼠标移动至少一次时创建PHP会话(Create PHP session when mouse moved at least once)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 前台提交数据到php mysql,建立一
- 下一篇: 睡眠面膜要洗掉睡觉吗