這回undefined
,即使var roommate
包含正確的值:爲什麼AJAX響應返回undefined?
JS
roommate = $("#roommate").val();
$.post('roommateSearch.php', 'val=' + $(roommate).val(), function (response) {
alert(response);
});
roommateSearch.php
<?php
$roommate = $_POST['val'];
echo "I got your value!".$roommate;
?>
啊!當然。我覺得自己像個白癡。這工作。我會在5分鐘內將答案標記爲正確(聲譽限制)。謝謝! – radleybobins 2011-12-23 01:26:45