我想發佈數據到一個PHP網站,其中只包含php代碼,應該在第一頁上點擊ID#mR-RateableFramePicture時執行。這是由一個Ajax請求完成:阿賈克斯datapost沒有得到低谷張貼網址
$('#mR-RateableFramePicture').dblclick(function() {
$.ajax({
type: "POST",
url: 'moduleRateable/scriptSavedStyle.php',
data: { rateableUserID: rateableUserID, rateablePictureID: rateablePictureID},
success: function() {
$('#DynamicContent').load('moduleRateable/scriptSavedStyle.php');
}
});
});
var rateableUserID = $('input[name="rateableUserID"]').val();
var rateablePictureID = $('input[name="rateablePictureID"]').val();
而且這裏的URL目的地其AJAX員額:
<?php
// Start the session (enable global $_SESSION variable).
session_start();
// Include database-link ($conn).
include '../../scriptMysqli.php';
// Make global variable to simple variable.
$userID = $_SESSION["ID"];
//Save the rateable style to one owns libary of saved styles.
$ratedUserID = $_POST['rateableUserID'];
$ratedPictureID = $_POST['rateablePictureID'];
$sql = $conn->query("UPDATE styles WHERE userID = '$ratedUserID;' AND
pictureID = '$ratedPictureID' SET savedByUser = '$userID'");
?>
我收到以下錯誤信息:
注意:未定義指數:rateableUserID在C:\ xampp \ htdocs \ mystyle \ app \ moduleRateable \ scriptSavedStyle.php上線12
注意:未定義索引:rateablePictureID in C:\ xampp \ htdocs \ mystyle \ app \ moduleRateab樂\ scriptSavedStyle.php上線13
您是否嘗試過在客戶端檢查兩者(請求頭髮送)和服務器端(在'$ _POST'全球)? – Terry
我試圖顯示變量rateableUserID與第一頁上的ajax請求內的警報,導致正確的值在JavaScript變量內但正如錯誤所示,是否沒有定義$ _POST變量:/ – Johannes
嘗試用'數據:{「rateableUserID」:rateableUserID,「rateablePictureID」:rateablePictureID}' – Niladri