php 鼠标小手,鼠标移动至少一次时创建PHP会话(Create PHP session when mouse moved at least once)...
鼠標移動至少一次時創建PHP會話(Create PHP session when mouse moved at least once)
我想在鼠標移動至少一次時創建php會話,如果鼠標繼續移動則不需要做任何事情
我正在使用此代碼,但它沒有解決要求
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
更新時間:2020-01-28 06:34
最滿意答案
PHP代碼應該是這樣的:
session_start();
if (!isset($_SESSION['mouseMoved'])
$_SESSION['mouseMoved'] = "whatever you want";
此外,您應該在JS中設置一些變量,以便僅將請求發送到服務器一次。
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
相關問答
要回顯會話,您需要調用session-variable,而不是與session-variable同名的常規變量。 所以你的回聲是: echo $_SESSION["AgreeNum"];
此外,如果您在寫入會話時遇到問題,則可能必須在向會話寫入任何內容之前調用session_start() 。 To echo your session you will need to call the session-variable, not a regular variable with the same
...
您已經在第2-3行發送
后嘗試發送Location標題。 你不能這樣做。 必須在發送任何輸出之前發送標頭。 老實說,我不知道你的代碼如何在你的本地服務器上工作。 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...
你有沒有在XAML中搞定你的活動? 例如
//Your Page
Have you hooked your event up in XAML? For Example
//Your Page
檢查包含的文件/代碼結構..導致此錯誤的常見原因是: session_start();
/* Random Code here /*
session_start();
只是session_start();的重復行session_start(); 因此,我建議查看您收到此錯誤消息的所包含文件/主頁,并檢查多個session_start(); Check over your included files/code structure.. A usual cause for this erro
...
首先,并非所有版本的窗口都會在鼠標移動時更改滾動條的顏色。 如果您發現在Windows XP中找不到此功能。 現在很奇怪你為什么要改變滾動條的顏色我不明白。 但是你想要的 將鼠標移到滾動上時會觸發的消息是什么? 當鼠標在滾動條上移動時調用其WM_NCMOUSEMOVE消息,因為滾動條也是非客戶區。 有關此問題的更多信息,您可以參考此鏈接, MFC MDI問題:檢測鼠標移動滾動條 First of all not all version of window changes the color of
...
根據此主題,此問題似乎是Chrome錯誤: 圖片在懸停時移動 - 鍍鉻不透明度問題 ,我認為您應該設置位置:相對于內部img解決問題 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方法都被調用嗎? 這是寫的方式,mouseMoved方法是PaintSurface的成員,但PaintSurface不是MouseMotionListener。 實現'MouseMotionListener'將強制它實現mouseMoved和mouseDragged 。 完成之后,您可以將自己的PaintSurface添加為自己作為MouseMotionListener 。 或者,您可以在已經定義的MouseMotionAdapter匿名類中移動mouseMoved
...
你確定你的瀏覽器正在接受它應該的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代碼應該是這樣的: session_start();
if (!isset($_SESSION['mouseMoved'])
$_SESSION['mouseMoved'] = "whatever you want";
此外,您應該在JS中設置一些變量,以便僅將請求發送到服務器一次。 更新:一個工作的jsfiddle https://jsfiddle.net/bqh0yrtp/ The PHP code should be something like this: session_
...
也許GetLastInputInfo就是你在這里需要的MSDN 。 例如,要獲取自上次鼠標移動或按鍵操作后經過的毫秒數,您可能具有如下函數: DWORD GetIdleTime()
{
LASTINPUTINFO pInput;
pInput.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&pInput))
{
// report error, etc.
}
...
總結
以上是生活随笔為你收集整理的php 鼠标小手,鼠标移动至少一次时创建PHP会话(Create PHP session when mouse moved at least once)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前台提交数据到php mysql,建立一
- 下一篇: 睡眠面膜要洗掉睡觉吗