Userfrosting システム (スリム フレームワークと twig を使用するシステム) で開発されたプロジェクトで ajax アクションを作成しようとしています。
section.php には、country と city という 2 つの html select タグがあります。国を選択すると、その国の都市がデータベースから選択され、ajax アクションで都市タグに表示されます。
これは通常の php スクリプトで実行できますが、slim では実行できません。
セクション.php
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".country").change(function() {
var veri = $(this).val();
var dataString = 'veri=' + veri;
$.ajax({
type: "POST",
url: "deneme.php",
data: dataString,
cache: false,
success: function(html) {
$(".city").html(html);
}
});
});
});
</script>
<label>Country :</label>
<select name="country" class="country">
<option selected="selected">--Select Country--</option>
<option value="1">India</option>
<option value="2">United States</option>
<option value="3">United Kingdom</option>
</select>
<br/>
<br/>
<label>City :</label>
<select name="city" class="city">
<option selected="selected">--Select City--</option>
</select>
投稿された値「veri」はdeneme.phpによって取得され、その国の都市がデータベースから取得され、すべての都市がオプションにリストされます。
deneme.php
require_once("../userfrosting/config-userfrosting.php");
require_once "../userfrosting/models/mysql/MySqlSiteSettings.php";
$veri = $app->request->post('veri');
if (isset($veri)) {
while ($data = $app->site->getCities($veri)) {
$cities = $data[city];
echo '<option value="'.$cities.
'">'.$cities.
'</option>';
}
国を選択すると、都市のオプションが空になり、エラー ログにこのエラーが表示されます。
「PHP 致命的エラー: 119 行目
getAktiviteler()
のオブジェクト以外のメンバー関数の呼び出し」C:\xampp\htdocs\userfrosting\public\deneme.php
私は多くの異なる方法を使用しましたが、問題を解決できませんでした。助けてください !