jq的代码示例如下,仅供参考:
$.getJSON("test.json", function(data){
html=""
$.each(data.img,function(i,e){
html+='<a href="http://'+data.url[i]+'" title=""><img src="'+e+'" lazy="loaded"></a>'
})
$("body").append(html)
})
使用ajax。
参考代码:
$(function(){
$.ajax({
type:"POST", url:"LoginLoadArticle.ashx",
data: "type="+escape("最新公告") ,
success:function(msg){
$(".gonggao").html(msg)
}, error:function(XMLHttpRequest, textStatus, thrownError){}})
})
扩展资料:
xml:返回XML文档,可用JQuery处理。
html:返回纯文本HTML信息;包含的script标签会在插入DOM时执行。
script:返回纯文本JavaScript代码。不会自动缓存结果。除非设置了cache参数。注意在远程请求时(不在同一个域下),所有post请求都将转为get请求。
json:返回JSON数据。
jsonp:JSONP格式。使用SONP形式调用函数时,例如myurl?callback=?,JQuery将自动替换后一个“?”为正确的函数名,以执行回调函数。
text:返回纯文本字符串。
beforeSend:要求为Function类型的参数,发送请求前可以修改XMLHttpRequest对象的函数。
载入远程 html 文件代码并插入至 dom 中。默认使用 get 方式 - 传递附加参数时自动转换为 post 方式。jq 1.2 中,可以指定选择符,来筛选载入的 html 文档,dom 中将仅插入筛选出的 html 代码。语法形如 url #some selector。请查看示例。----------------------------------------load html from a remote file and inject it into the dom.a get request will be performed by default - but if you pass in any extra parameters then a post will occur. in jq 1.2 you can now specify a jq selector in the url. doing so will filter the incoming html document, only injecting the elements that match the selector. the syntax looks something like url #some selector. see the examples for more information.返回值jq参数url (string) : 待装入 html 网页网址。data (map) : (可选) 发送至服务器的 key/value 数据。callback (callback) : (可选) 载入成功时回调函数。示例加载文章侧边栏导航部分至一个无序列表。html 代码:<bjq links:</b<ul id=links</uljq 代码:$(#links).load(/main_page #p-getting-started li)----------------------------------------加载 feeds.html 文件内容。jq 代码:$(#feeds).load(feeds.html)----------------------------------------同上,但是以 post 形式发送附加参数并在成功时显示信息。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)