Ajax : $. get()和$.post() $.getScript $.getJSON
<body>
<input type="button" value="Ajax" />
<div id="box"></div>
</body>
test.html
<span class="name">党兴明</span>
<span class="age">24</span>
test.php
<?php
// if($_POST['age'] == 24){
// echo 'php:党兴明24';
// }else{
// echo '木有';
// }
if($_GET['age'] == 24){
echo 'php:党兴明24';
}else{
echo '木有';
}
?>
test.xml
<?xml version="1.0"?>
<root>
<url>www.ycku.com</url>
</root>
test.josn
[
{
"url" : "www.ycku.com"
}
]
$. get():
//1 三种传值
$('input').click(function(){
$.get('test.php?age=24',function(response,status,xhr){
$('#box').html(response);
});
});
//2
$('input').click(function(){
$.get('test.php','age=24',function(response,status,xhr){
$('#box').html(response);
});
});
//
$('input').click(function(){
$.get('test.php',{
age:24
},function(response,status,xhr){
$('#box').html(response);
});
});
$.post()
//1 两种传值
$('input').click(function(){
$.post('test.php','age=24',function(response,status,xhr){
$('#box').html(response);
});
});
//
$('input').click(function(){
$.post('test.php',{
age:24
},function(response,status,xhr){
$('#box').html(response);
});
});
读取.xml和.josn文件:
$('input').click(function(){
$.post('test.xml',function(response,status,xhr){
$('#box').html($(response).find('root').find('url').text());
});
});
$('input').click(function(){
$.post('test.json',function(response,status,xhr){
$('#box').html(response[0].url);
});
});
$.getScript()
$('input').click(function(){
$.getScript('js/test.js');
});
$.getJSON()
$('input').click(function(){
$.getJSON('test.json',function(response,status,xhr){
$('#box').html(response[0].url);
});
});
Ajax : $. get()和$.post() $.getScript $.getJSON的更多相关文章
- jQuery 中的 Ajax $.ajax() load() $.get() $.post() $.getJSON() $.getScript()
1. $.ajax()方法 参数对象属性如下: 参数名 类型 描述 url String (默认: 当前页地址) 发送请求的地址. type String (默认: "GET") ...
- jQuery 之 $.get、$.post、$.getJSON、$.ajax
对 JSTL标签 加以巩固,同时在自己的博客中与之分享: http://app.yinxiang.com/shard/s20/sh/76feadb0-957a-40bc-895d-4d28025ce2 ...
- Flask与Ajax
这篇短文使用jquery. Flask提供一个很简单的方法来处理Ajax请求——在视图函数中用request的属性is_xhr来判断,如果是true则是异步请求. Jquery的$.getJSON() ...
- Asp.Net MVC 使用 Ajax
Asp.Net MVC 使用 Ajax Ajax 简单来说Ajax是一个无需重新加载整个网页的情况下,可以更新局部页面或数据的技术(异步的发送接收数据,不会干扰当前页面). Ajax工作原理 Ajax ...
- ABP文档 - Javascript Api - AJAX
本节内容: AJAX操作相关问题 ABP的方式 AJAX 返回信息 处理错误 HTTP 状态码 WrapResult和DontWrapResult特性 Asp.net Mvc 控制器 Asp.net ...
- [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...
- jQuery系列:Ajax
1. load(url, [data], [callback]) 1.1 解析 载入远程 HTML 文件代码并插入至 DOM 中. 语法格式: load(url, [data], [callback] ...
- getJson
$.getJSON("<%=basePath%>delivery/auditing.do",{Phones:Phones,currPage:currPage,timst ...
- jQuery的$.ajax
在介绍JSONP之前,先简单的介绍一些JSON.JSON是JavaScript Object Notation的缩写,是一种轻量的.可读的基于文本的数据交换开放标准.源于JavsScript编程语言中 ...
- 前端之ajax
前端之ajax 本节内容 ajax介绍 原生js实现ajax jquery实现ajax json 跨域请求 1. ajax介绍 AJAX(Asynchronous Javascript And XML ...
随机推荐
- KM HDU 3718
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...
- C#做的CPU内存使用率
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 前端编程提高之旅(十二)----position置入值应用
这次内推项目用到的遮罩及其页面下方button都涉及一个概念position置入值得概念.效果图例如以下: 一个元素position属性不是默认值static.那么该元素被称为定位元素. 定位的元素生 ...
- [python]pip坏了怎么办?
今天,给一位新同事配置pip,用get-pip.py安装之后.出现错误: raise DistributionNotFound(req) # XXX put more info here pkg_r ...
- 深入理解maven及应用(一):生命周期和插件
在项目里用了快一年的maven了,近期突然发现maven项目在eclipse中build时很慢,由于经经常使用clean install命令来build项目,也没有管那么多,但近期实在受不了乌龟一样的 ...
- FPGA design flow
FPGA engineering process usually involves the following stages: Architecture design. This stage invo ...
- BZOJ 1503 treap
思路: treap (算是基本操作吧-..) 加减的操作数很少 就暴力好啦 每回判断一下最小的数是不是比M小 如果是 就删,继续判断 搞定. //By SiriusRen #include <c ...
- ps切图时常用的操作与快捷键
一:两种切片方法 第一种: 1.使用切片工具划分好你要切的模块 2.点击'存储为web所有格式',在存储之前可以修改图片的品质来改变文件的大小. 3.在存储时切片有三种选择方式,按照自己的需要选择. ...
- nginx下修改svn配置
最近公司的SVN服务器地址做了变更,而我用的操作系统是Ubuntu操作系统,我也不想把以前下载的代码重新进行修改,我想通过修改svn地址,应该可以,终于在网上通过查找资料,找到了解决的方法: ...
- python + eclipse + django + postgresql 开发网站(一)
一.配置开发环境 1.安装Python 载地址下:http://www.python.org/getit/