jquery中ajax完整例子 jQuery中data()方法用法實例?
jQuery中data()方法用法實例?//登錄函數(shù)loginaajax(param){var self=this$。Ajax({type:“post”,URL:“user/login”,dataty
jQuery中data()方法用法實例?
//登錄函數(shù)loginaajax(param){var self=this$。Ajax({type:“post”,URL:“user/login”,datatype:“JSON”,data:param,success:function(data){},error:function(error){控制臺.log(錯誤)}1。上面是一個登錄Ajax方法,參數(shù)說明URL:請求數(shù)據(jù)的鏈接地址:請求參數(shù)以JSON格式傳遞,例如:{Username:“name”,password:“123456”}type:常用的請求方法是get或post,默認為get request。數(shù)據(jù)類型:服務(wù)器預期返回的數(shù)據(jù)類型。2下面是正式j(luò)Query文檔中的Ajax請求代碼:$。Ajax({類型:“post”,URL:“some.php文件,數(shù)據(jù):“name=John&location=Boston”,成功:函數(shù)(msg){警報(“數(shù)據(jù)已保存:”msg)})