@RequestMapping("/hello")
    @ResponseBody
    public Hello getJson(HttpServletRequest request,HttpServletResponse response,Model model){
            Hello hello=new Hello();
            hello.setStr("hello world");
        return hello;
    }

<span id="hello">hello</span>

//post请求

$("#hello").click(function(){
    $.post("${ctx}/partner/hello",function(data){alert(data.str);},"json");
});

//ajax请求

$("#hello").click(function(){
    $.ajax({
         type: "POST",
         url: "${ctx}/partner/hello",
         dataType:"json",
         success: function(data){
           alert( "data: " + data.str );
         }
    });
});

jquery ajax/post 请求 案例的更多相关文章

  1. jquery Ajax请求示例,jquery Ajax基本请求方法示例

    jquery Ajax请求示例,jquery Ajax基本请求方法示例 ================================ ©Copyright 蕃薯耀 2018年5月7日 https: ...

  2. jquery Ajax异步请求之session

    写了一个脚本,如下: $(function () { $("#btnVcode").click(function () { var receiveMobile = $(" ...

  3. jQuery Ajax(异步请求)

    jQuery异步请求 原始的异步请求是需要创建的 XMLHttpRequest 对象.(IE5,6不支持)目前很多浏览器都支持XMLHttpRequest对象 jQuery ajax常用的回调函数:b ...

  4. JQuery Ajax 发送请求成功后却接收不到任何响应数据问题

    问题描述 使用 JQuery Ajax 向后端服务器发送请求,服务器也收到请求返回了响应数据,但是 Ajax 却收不到任何响应数据. 举例如下: $.ajax({ type: "post&q ...

  5. JQuery Ajax 设置请求头信息application/json

    今天有个api后台接application/json格式的 在Jquery里$.ajax默认是contentType: application/x-www-form-urlencoded; chars ...

  6. jquery ajax异步请求

    得先知道后台接口给ajax访问(接口URl和传入接口的参数及参数类型),知道访问之后返回的数据类型,有哪些数据.   选择异步请求的方式,常用的有三种,如$.ajax().$.post().$.get ...

  7. jquery ajax post请求实例

    function test(){ $.ajax({ //提交数据的类型 POST GET type:"POST", //提交的网址 url:"testLogin.aspx ...

  8. jquery ajax 设置请求头header 参数

    $.ajax( { url:'http://127.0.0.1:30080/api-a/quasiCustom/selectCustomList', type:'post', dateType:'js ...

  9. [jQuery]ajax同步请求在方法内问题

    在函数内写$.ajax() 的成功函数中return 的值,并没有return到外层方法返回至

随机推荐

  1. scrapy的CrawlSpider使用

    1.创建项目 我这里的项目名称为scrapyuniversal,然后我创建在D盘根目录.创建方法如下 打开cmd,切换到d盘根目录.然后输入以下命令: scrapy startproject scra ...

  2. mininet+floodlight搭建sdn环境并创建简单topo

    第一步:安装git sudo apt-get update sudo apt-get install git 测试git是否安装成功: git 第二步:安装mininet 1.获取mininet最新源 ...

  3. 【bzoj3261】最大异或和

    就是一个可持久化Trie....... #include<bits/stdc++.h> #define N 600005 using namespace std; inline int r ...

  4. Linux编写Shell脚本

    ——<Linux就该这么学>笔记Shell脚本命令的工作方式有两种 交互式: 用户每输入一条命令就立即执行 批处理: 由用户事先编写好一个完整的Shell脚本,Shell会一次性执行脚本中 ...

  5. 杀掉MYSQL死锁进程

    vi /usr/local/killmysqlprocess.sh #!/bin/bash #*/1 * * * * /usr/local/src/killmysqlprocess.sh backdi ...

  6. MYSQL的内外连接

    1.内联接(典型的联接运算,使用像 =  或 <> 之类的比较运算符).包括相等联接和自然联接.     内联接使用比较运算符根据每个表共有的列的值匹配两个表中的行.例如,检索 stude ...

  7. django URL参数在view中传递和Template的反向解析方式

    一. URL参数在view中传递 1.带参数名:通过named group方式传递指定参数,语法为: (?P<name>pattern), name 为传递参数的名称,pattern代表所 ...

  8. POJ 2503.Babelfish-sscanf()函数+strcmp()函数+二分

    Babelfish   Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 44545   Accepted: 18803 Des ...

  9. CSS 从入门到放弃系列:CSS的引入方式

    css的四种引入方式 内联方式(行间样式) <div style="width:100px;height: 100px; background-color: red"> ...

  10. RabbitMQ使用介绍(python)

    在我们的项目开发过程中,我们有时会有时候有两个或者多个程序交互的情况,当然就会使用到这里的消息队列来实现.现在比较火的就是RabbitMQ,还有一些ZeroMQ ,ActiveMQ 等等,著名的ope ...