2017-08-14 93 views
-3

在php中,我想使用jquery.post方法傳遞一個php變量。在javascript中發佈到php變量

第一個圖顯示該訊息的可變 first

第二圖顯示讀取張貼變量的代碼。 second

php變量包含一些語句,但輸出將打印變量名稱,如「$ rxss」,「$ sxss」。

該post方法似乎是不正確地寫入數據部分,所以請讓我知道如何寫它。

添加

我已經測試

echo '<script type="text/javascript"> 
$(document).ready(function() { 
$.post("scanner/getStatus.php", {testId:' . "$testId" . ',chkCnt:' . "$chkCount" . ',rxss:' . "$rxss" . ',sxss:' . "$sxss" . ',sqli:' . "$sqli" . ',basqli:' . "$basqli" . ',autoc:' . "$autoc" . ',idor:' . "$idor" . ',dirlist:' . "$dirlist" . ',bannerdis:' . "$bannerdis" . ',sslcert:' . "$sslcert" . ',unredir:' . "$unredir" . ',clamav:' . "$clamav" . '}, function(data){$("#status").html(data)}); 
    var refreshId = setInterval(function() { 
$.post("scanner/getStatus.php", {testId:' . "$testId" . ',chkCnt:' . "$chkCount" . ',rxss:' . "$rxss" . ',sxss:' . "$sxss" . ',sqli:' . "$sqli" . ',basqli:' . "$basqli" . ',autoc:' . "$autoc" . ',idor:' . "$idor" . ',dirlist:' . "$dirlist" . ',bannerdis:' . "$bannerdis" . ',sslcert:' . "$sslcert" . ',unredir:' . "$unredir" . ',clamav:' . "$clamav" . '}, function(data){$("#status").html(data)}); 
}, 500); ...... 

-

echo '<script type="text/javascript"> 
$(document).ready(function() { 
$.post("scanner/getStatus.php", {testId:' . "$testId" . ',chkCnt:' . "$chkCount" . ',rxss:"" + $rxss + "",sxss:"" + $sxss + "",sqli:""+ $sqli + "",basqli:"" + $basqli + "",autoc:"" + $autoc + "",idor:"" + $idor + "",dirlist:"" + $dirlist + "",bannerdis:"" + $bannerdis + "",sslcert:"" + $sslcert + "",unredir:"" + $unredir + "",clamav:"" + $clamav + ""}, function(data){$("#status").html(data)}); 
    var refreshId = setInterval(function() { 
$.post("scanner/getStatus.php", {testId:' . "$testId" . ',chkCnt:' . "$chkCount" . ',rxss:"" + $rxss + "",sxss:"" + $sxss + "",sqli:""+ $sqli + "",basqli:"" + $basqli + "",autoc:"" + $autoc + "",idor:"" + $idor + "",dirlist:"" + $dirlist + "",bannerdis:"" + $bannerdis + "",sslcert:"" + $sslcert + "",unredir:"" + $unredir + "",clamav:"" + $clamav + ""}, function(data){$("#status").html(data)}); 
}, 500); ...... 

但是當這些測試沒有顯示getStatus.php和Apache日誌沒有錯誤

+0

因爲你使用簡單的引號來回顯你的html,所以它打印它的字面意思你已經做了相同的,你用$ testId(和你不需要使用雙引號,當你連接php中的變量) – MacBooc

+2

將您的代碼作爲代碼添加到問題中。 **不要**發佈代碼作爲截圖/圖片。 – ThiefMaster

回答