如何使用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" />