如何使用ajax發佈多個數據?我想發佈輸入value
和attr
兩者。下面是一個例子:Ajax發佈多個數據
$('.input[type=\'text\']').keyup(function(){
$.ajax({
type: 'POST',
url: 'index.php',
data: $('.input[type=\'text\']'),
dataType: 'json',
success: function(json) {
alert('done');
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" value="" attr="yes" />