저는 AJAX를 통해 매우 기본적인 PHP 코드를 실행하고 PHP 페이지에서 AJAX 성공으로 데이터를 다시 가져 오려고합니다.AJAX에서 성공한 PHP 데이터?
그러나 PHP 페이지에서 AJAX 성공과 나쁘게 도청 한 점은 없습니다.
이는 AJAX 코드 :
$(document).ready(function(){
$(function(){
$('#form-post').on('submit', function(e){
// prevent native form submission here
e.preventDefault();
// now do whatever you want here
$.ajax({
type: $(this).attr('method'), // <-- get method of form
url: $(this).attr('action'), // <-- get action of form
data: $(this).serialize(), // <-- serialize all fields into a string that is ready to be posted to your PHP file
beforeSend: function(){
//$('#result').html('<img src="loading.gif" />');
},
success: function(data){
$('#messageme').html(data);
}
});
});
});
});
이는 형태 :
<form id="form-post" action="post-code.php" method="post" >
<input type="hidden" value="Post" name="submit" />
<input type="text" class="inp-form" name="postcode" id="postcode" placeholder="Enter Post Code " /><br /><br /><input type="text" id="messageme" /><br /><br />
<input id="findAd" type="button" value=" Search For Address" />
</form>
매우 간단한 PHP :
<?php
$street = "some";
echo $street;
?>
사람이에 대한 조언을주십시오 수 있을까?
이 $ ('# messageme')을 시도하십시오 .val (data); – AVM
데이터 형식 추가 : 'html' –
@AVM, 아니요, 불행히도 나는 아무것도 얻지 못합니다! – william