0
I以下のAjaxリクエストがありますPHP/jQueryのAjaxのリターンSQLiteの文字列
getContent.phpgetContent.phpは非常に簡単ですで私のPHPスクリプトに単一の値を送信している
$.ajax({
type: "POST",
url: "getContent.php",
dataType: "text",
data: { "contentid": contentID },
success: function (data) {
console.log("Received: " + data);
}
});
}
、おもう。
<?php
// Set up connection to sqlite
try {
$myPDO = new PDO('sqlite:freezy.sqlite');
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
$id = $_POST['contentid'];
// Prepare an update statement
$sql = "select contentBlock from content where contentId = :contentIDTarget";
// formalise the statement
$stmt = $myPDO->prepare($sql);
// passing values to the parameters
$stmt->bindValue(':contentIDTarget', $id);
// Execute the update
$result = $stmt->execute();
echo $result;
?>
このデータベースは、同じデータベースに対してslqiteテストツールでテストしたときに正常に動作します。
私はしかし、これを使用しようと、私は 「受信:」上のコンソールログに表示さのすべての行がある:受信
:私は見て期待していた何1
のようなものでした。 受信:
テストテキスト
結果には、tinyMCEからそこに配置されたコンテンツが含まれている必要があるためです。
私には何が欠けていますか?操縦者に大いに感謝します。
ありがとう@TimBrownlaw - 大変感謝しています! 私は今使用しています: //更新を実行 $ stmt-> execute(); $結果= $ sth->フェッチ(PDO :: FETCH_ASSOC); echo $ result ['contentBlock']; とAjaxリクエストで私が使用しています: $アヤックス({ タイプ: "POST"、 URL: "getContent.php"、 データ:{ "コンテンツID":コンテンツID}、 成功:機能(データ){ console.log( "受信:" +データ); } }); } しかし、私は500のサーバーエラーが発生しています。まだチェック中... – user3202399