<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function(){
var from=$('input#searchfrom').val();
var to=$('input#searchto').val();
datastring="from="+from+"&to="+to;
$.ajax({
type: "POST",
url: "measure.php",
data: dataString,
cache: false,
beforeSend: function(){ $("#btn").val('Connecting...').delay(6000);},
success:function(response){
$('#result').html(response);}
});
});
});
</script>
關注傳遞多個數據是保存值的元素在阿賈克斯
From-<input id="searchfrom" type="text" size="50" placeholder="Enter a location" autocomplete="on">
To-<input id="searchto" onblur="" type="text" size="50" placeholder="Enter a location" autocompete="on" >
<div id="result"></div>
<button type="button" id="btn" >Click</button>
的Ajax功能不能通過數據mesaure頁,但它的正常工作,當一個參數傳遞,請幫我解決掉這個問題謝謝。
做你''console.log'和from''to'的價值? – Drudge