<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);
});
});

最新文章

  1. 【Centos】修改网卡名字&amp;随之出现的问题
  2. ThoughtWorks代码挑战——FizzBuzzWhizz
  3. Leetcode: Sort Transformed Array
  4. 我眼中的WebViewJavascriptBridge
  5. MS SQL Server 2008 R2 常规操作
  6. JavaScript变量声明var,let.const
  7. mysql之外键
  8. tensorflow-gpu安装的一些注意
  9. 潭州课堂25班:Ph201805201 django 项目 第九课 图片验证码前台实现,判断用户是否注册功能实现 (课堂笔记)
  10. 由于php环境时间与北京时间相差7个小时
  11. GRU
  12. 在JavaScript里写类层次结构?别那么做!
  13. Codeforces 395 D.Pair of Numbers
  14. laravel中form表单,ajax传值没反应
  15. vue打包后运行在本地/非服务器端环境的访问路径
  16. android回调函数
  17. hdu5739
  18. ImageSwitch图像切换控件
  19. #include &quot;*.c&quot;文件的妙用
  20. wewe

热门文章

  1. 做一个萌萌哒的button之box-shadow
  2. Java 中的事件监听机制
  3. LeetCode_Construct Binary Tree from Inorder and Postorder Traversal
  4. C++ STL:vector
  5. sass01
  6. BZOJ 1305 二分+网络流
  7. android学习笔记五。2、其他组件
  8. 解决plsql遇到乱码的问题
  9. C# Aspose.Cells 使用汇总
  10. 计算机科学书籍推荐和CSS、js书籍推荐