フォームで2つのAJAX呼び出しを行っています。最初は、PHPページを呼び出してデータを処理する最初の選択に基づいて2番目の選択を変更することです。 2番目はデフォルトの投稿を防止し、別のPHPページにデータを投稿することです。AJAXを使用してpreventDefaultで別のajaxを使用しているときに関数を呼び出す
もう1つを削除すると、両方の機能が動作しています。私はまた、新しいページへのリダイレクト(CleanURLを使用して)という別の問題を抱えています。投稿ページでリダイレクトする必要がありますか、またはフォームページに戻ったらどこですか?あなたはtestform
<form id="testform">...
にIDが欠落している
$('#brand').change(function() {
var brandID2 = $(this).val();
$.ajax({
url: "Calling the models after selecting the brand",
method: "POST",
data: {
brandID: brandID2
},
dataType: "text",
success: function(data) {
$('#model').html(data);
}
});
});
$("#testform").on('submit', (function(e) {
e.preventDefault();
$.ajax({
url: "Calling the post page",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(data) {
//window.location.href = "<?php echo $_SESSION['toRedirectToAfterFilters']; ?>";
}
});
}));
<form name="testform" action="" method="POST">
<select name="brand" id="brand">
<option value=''>Select a Brand</option>
//function to load all the brands
</select>
<select name="model" id="model">
<option value="">Please Select Brand First</option>
</select>
<button type="submit" name="submit" class="">FILTER</button>
</form>
「もう1つを削除すると、両方の機能が動作しています。」 –
最初のものを削除して2番目のものを削除すると、最初のものが削除されます – Da3kariS