<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的更多相关文章

  1. jQuery 中的 Ajax $.ajax() load() $.get() $.post() $.getJSON() $.getScript()

    1. $.ajax()方法 参数对象属性如下: 参数名 类型 描述 url String (默认: 当前页地址) 发送请求的地址. type String (默认: "GET") ...

  2. jQuery 之 $.get、$.post、$.getJSON、$.ajax

    对 JSTL标签 加以巩固,同时在自己的博客中与之分享: http://app.yinxiang.com/shard/s20/sh/76feadb0-957a-40bc-895d-4d28025ce2 ...

  3. Flask与Ajax

    这篇短文使用jquery. Flask提供一个很简单的方法来处理Ajax请求——在视图函数中用request的属性is_xhr来判断,如果是true则是异步请求. Jquery的$.getJSON() ...

  4. Asp.Net MVC 使用 Ajax

    Asp.Net MVC 使用 Ajax Ajax 简单来说Ajax是一个无需重新加载整个网页的情况下,可以更新局部页面或数据的技术(异步的发送接收数据,不会干扰当前页面). Ajax工作原理 Ajax ...

  5. ABP文档 - Javascript Api - AJAX

    本节内容: AJAX操作相关问题 ABP的方式 AJAX 返回信息 处理错误 HTTP 状态码 WrapResult和DontWrapResult特性 Asp.net Mvc 控制器 Asp.net ...

  6. [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结

    本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...

  7. jQuery系列:Ajax

    1. load(url, [data], [callback]) 1.1 解析 载入远程 HTML 文件代码并插入至 DOM 中. 语法格式: load(url, [data], [callback] ...

  8. getJson

    $.getJSON("<%=basePath%>delivery/auditing.do",{Phones:Phones,currPage:currPage,timst ...

  9. jQuery的$.ajax

    在介绍JSONP之前,先简单的介绍一些JSON.JSON是JavaScript Object Notation的缩写,是一种轻量的.可读的基于文本的数据交换开放标准.源于JavsScript编程语言中 ...

  10. 前端之ajax

    前端之ajax 本节内容 ajax介绍 原生js实现ajax jquery实现ajax json 跨域请求 1. ajax介绍 AJAX(Asynchronous Javascript And XML ...

随机推荐

  1. hadoop 2.5.1 、Hadoop 2.7 Hadoop 2.6

    1  rpm 安装     yum install rpm 2  JDK安装    << 一定要先删除JDK!!!!!!>>       rpm -qa | grep java ...

  2. Android4.42-Settings源代码分析之蓝牙模块Bluetooth(上)

    继上一篇Android系统源代码剖析(一)---Settings 接着来介绍一下设置中某个模块的源代码.本文依然是基于Android4.42源代码进行分析,分析一下蓝牙模块的实现.建议大致看一下关于S ...

  3. cf 828 A. Restaurant Tables

    A. Restaurant Tables time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. PatentTips - Device virtualization and assignment of interconnect devices

    BACKGROUND Standard computer interconnects, particularly for personal computers or workstations, may ...

  5. class-dump 和 iOSOpenDev 的使用

    class-dump 官网地址:这里 我这里下载的是 class-dump-3.5.dmg 版本号的. 双击.dmg 文件,将  拉倒 /usr / local / bin 文件夹下,这样就能够在终端 ...

  6. Struts(18)标签

    控件标签 Struts 2 的标签有一组标签.更easy控制流程页面运行.下面是重要的Struts2控制标签列表: if /else 标签: 这些标签运行可在每一种语言找到的一种基本条件流程. 'If ...

  7. UI_搭建MVC

    新建RootViewController 继承于 UIViewController 新建RootView 继承于 UIView AppDelegate.m 中引入 #import "Root ...

  8. Python 数据结构与算法 —— 哈弗曼树

    1. 从扩充二叉树到哈弗曼树 扩充二叉树:对二叉树 T,加入足够多的新叶节点(而不是任意),使 T 的原有结点都变成度数为 2 的分支节点,得到的二叉树称为 T 的扩充二叉树. 对于扩充二叉树而言, ...

  9. Onvif开发之服务端发现篇

    服务端的开发相对来说比客户端稍微难一点,也就是给填充相关结构体的时候,需要一点一点的去查阅,验证各个结构中各个成员各自代表什么意思,以及对应的功能需要是那个接口实现,这是开发服务端最头疼的事情.(在开 ...

  10. vue -- 动态加载组件 (tap 栏效果)

    在 vue 中,实现 Tab 切换主要有三种方式:使用动态组件,使用 vue-router 路由,使用第三方插件. 因为这次完成的功能只是简单切换组件,再则觉得使用路由切换需要改变地址略微麻烦,所以使 ...