PHPスクリプトで値が空であればそれを設定します。私は値が空であるというメッセージをコンソールに表示し続けますが、なぜ私に価値があるように見えるのかわかりません。PHPは値が空であることを伝え続けます
varが存在する場合はここではPHP
ここ$percentageOfMessages = $_POST["percentageOfMessages"];
$RemoveDeletedAccounts = $_POST["RemoveDeletedAccounts"];
$RemoveNoReply = $_POST["RemoveNoReply"];
$RemoveNoResponse = $_POST["RemoveNoResponse"];
$mintchPercent = $_POST["mintchPercent"];
$minDistance = $_POST["minDistance"];
$maxDistance = $_POST["maxDistance"];
$blacklistUsernames = $_POST["blacklistUsernames"];
$pickText = $_POST["pickText"];
$userEmail = $_POST["userEmail"];
//$captcha = $_POST["captcha"];
//$num1 = $_POST["num1"];
//$num2 = $_POST["num2"];
if (empty($percentageOfMessages)) {
echo "percentageOfMessages";
}elseif (empty($mintchPercent)) {
echo "mintchPercent";
}elseif (empty($minDistance)) {
echo "minDistance";
}elseif (empty($maxDistance)) {
echo "maxDistance";
}elseif (empty($pickText)) {
echo "pickText";
}elseif (empty($userEmail)) {
echo "userEmail";
}else {
ではJavaScript/minDistance
$('#minDistance').keyup(function() {
if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
this.value = this.value.replace(/[^0-9\.]/g, '');
} else if ($(this).val() > 500) {
$(this).val('500');
} else if ($(this).val() < 0) {
$(this).val('0');
}
});
$('#minDistance').blur(function() {
if ($(this).val() > $('#maxDistance').val()) {
$(this).val('0');
}
});
function sendForm(e) {
e.preventDefault();
var formData = new FormData();
formData.append('percentageOfMessages', $('#percentageOfMessages').val());
if ($('RemoveDeletedAccounts').prop('checked')) {
formData.append('RemoveDeletedAccounts', "1");
} else {
formData.append('RemoveDeletedAccounts', "0");
}
if ($('RemoveNoReply').prop('checked')) {
formData.append('RemoveNoReply', "1");
} else {
formData.append('RemoveNoReply', "0");
}
if ($('RemoveNoResponse').prop('checked')) {
formData.append('RemoveNoResponse', "1");
} else {
formData.append('RemoveNoResponse', "0");
}
formData.append('minMatchPercent', $('#minMatchPercent').val());
//OTHER STUFFFFFFFFF
$.ajax({
type: 'POST',
xhr: function() { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { // Check if upload property exists
//myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
}
return myXhr;
},
cache: false,
processData: false,
contentType: false,
data: formData,
url: 'addAccounts.php',
success: function(data) {
console.log(data);
},
error: function(xhr, err) {
console.log("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
console.log("responseText: " + xhr.responseText);
}
});
}
を関与jQueryとここにHTMLで
<div class="row uniform">
<div class="6u 12u$(xsmall)">
<input type="text" name="minDistance" id="minDistance" value="0" />
</div>
<div class="6u 12u$(xsmall)">
<input type="text" name="maxDistance" id="maxDistance" value="500" />
</div>
</div>
'formData'はどのようにサーバーに送られますか? –
@ArunPJohny Ajaxに関する質問を更新しました – PhpisHardForMe
console.logはデータを記録していますか? –