首页 > 代码库 > jq ajax

jq ajax

<script>
/* $(document).ready(function() {

$("#clearCac").click(function() {
var user = $(‘#user‘).val();
var password = $(‘#password‘).val();
$.ajax({
url: "xx.php",
type: "post",
data: { user: user,password:password},
dataType: "json",
success:function(data) {
console.log(data)
$(‘p span‘).text(data.news)
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(‘发送错误‘)
},
complete: function(XMLHttpRequest, textStatus) {
// 调用本次AJAX请求时传递的options参数

}
});
});
});*/
$(function(){
var user = $(‘#user‘).val();
var password = $(‘#password‘).val();
$.ajax({
url: "xx.php",
type: "post",
data: { user: user,password:password},
dataType: "json",
success:function(data) {
console.log(data)
$(‘p span‘).text(data.news)
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(‘发送错误‘)
},
complete: function(XMLHttpRequest, textStatus) {
// 调用本次AJAX请求时传递的options参数

}
});
})
</script>

jq ajax