我的JS:Ajax調用保持返回null
$('#select').change(function() {
var name = $(this).val();
$.ajax({
type: "POST",
url: "data/grab.php",
data: { type: "hops", name: name },
dataType: "json",
success: function(data) {
alert(data);
var aa = data['aa'];
$('#hops-aa').val(aa);
}
});
});
grab.php
<?php
$type = $_POST['type'];
$name = $_POST['name'];
if ($type == 'hops') {
$result = $name;
}
$result = json_encode($result);
return $result;
我在Ajax調用添加alert()
仔細檢查什麼,我從劇本找回,並它始終爲空。我錯過了什麼?
啊,謝謝。忘了這個。 – n0pe