jQ 中 ajax 及其配置参数
$.ajax({url: 'data/product.json', // 接口地址method: 'GET', // http methoddataType: 'json', // 数据类型为 JSONasync: false, // 异步与否,默认异步cache: false, // 是否设置缓存 true 表示缓存,falas 表示不缓存;一般设为 falsesuccess: function (result) { // 如果请求成功执行的操作console.log(result);},error: function (err) { // 如果失败,需要进行的操作console.log(err);}});
- $.ajax() 是通过 $ 调用的,说明 ajax 方法是定义在 jQuery 自身上的,而 css,html,animate 等都是定义在 jQ 原型上的方法。
