Jquery
来源:互联网 发布:杰拉德华莱士数据 编辑:程序博客网 时间:2024/05/22 00:48
使用Ajax
Jquery 封装了操作Ajax的函数。 有三个函数是常用的: get, post 和 ajax。 ajax可以设置更多的参数,比另外2个好用。
由于Ajax调用的网址是外部的,所以函数执行有同步和异步之分别。异步执行时,函数立即返回。我不知道在异步模式下是否有消息通知的机制,目前还没有找到,如果有的话更新。
use as this:
$.get(url,function(data){ jsonObj = JSON.parse(data); $("#txtStatus").text( "DB connected. There is(are) " + jsonObj.Count + " record(s)." ); $(":input[name='prodList']").val(jsonObj.Products); alert("Data Loaded: " + jsonObj); });
If you want to use synchronous mode with Ajax, use as this:
$.ajax({ async: false, type: "POST", url: url, contenttype: "application/json", datatype: "json", data: jsonObj, success: function(jsonResult) { $("#txtPrice").text(jsonResult); } });
Jquery的Selector
$("#txtStatus").text( "DB connected. Record count: " );$(":input[name='btn-price']").click(function () { var pname = $(":input#txtProd").val(); var url = "test1-hint.php?r=2&p=" + pname; $.ajax({ async: false, type: "POST", url: url, contenttype: "application/json", datatype: "json", data: jsonObj, success: function(jsonResult) { $("#txtPrice").text(jsonResult); } }); });
0 0
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQUERY
- jquery
- jQuery
- jquery
- jquery
- 常见算法在实际项目中的应用
- 随机读取几条文章的sql写法
- Linux16.04配置tensorflow(GPU源码编译)并深入了解tensorboard
- 解决导出excel时出现的日期变#号,长数字变科学记数法的问题
- bzoj1228: [SDOI2009]E&D
- Jquery
- lintcode(371)用递归打印数字
- PAT1029 旧键盘
- inner join on, left join on, right join on详细使用方法
- 使用谷歌翻译pdf内容小技巧——快速替换换行
- 同步 异步 回调
- jdk源码剖析之ArrayList
- 开源 java CMS
- 深度学习tensorflow安装ubuntu16.04amd64