How to handle jQuery.ajax(..) JSON request ?
来源:互联网 发布:java二进制流转字符串 编辑:程序博客网 时间:2024/06/06 02:52
Apache Wicket > Framework Documentation > Reference library > How to do things in Wicket > AJAX > How to handle jQuery.ajax(..) JSON request ?
Apache Wicket
How to handle jQuery.ajax(..) JSON request ?
#editReport()
The following is the jQuery JSON request code
This section of code invokes a abstract behavior ona page with a json request:
console.log(" call back url :"+ callBackURL); $.ajax({ url: callBackURL, type: 'post', cache: false, data:JSON.stringify(ccbArry), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function(json) { console.log(" reponse :"+ json); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("error :"+XMLHttpRequest.responseText); } });
This section of code is an abstract ajax behavior which accepts a json document in request and responds with another json document that is then available to the javascript method on the page.
AbstractAjaxBehavior ajaxSaveBehaviour = new AbstractAjaxBehavior(){ private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") public void onRequest() { //get parameters final RequestCycle requestCycle = RequestCycle.get(); WebRequest wr=(WebRequest)requestCycle.getRequest(); HttpServletRequest hsr= wr.getHttpServletRequest() ; try { BufferedReader br = hsr.getReader(); String jsonString = br.readLine(); if((jsonString==null) || jsonString.isEmpty()){ logger.error(" no json found"); } else { logger.info(" json is :"+ jsonString); } } catch (IOException ex) { logger.error(ex); } // json string to retir to the jQuery onSuccess function String data=getReturnJSONValue(); logger.info("returning json :"+ data); IRequestTarget t = new StringRequestTarget("application/json", "UTF-8", data); getRequestCycle().setRequestTarget(t); //requestCycle.setRequestTarget(new StringRequestTarget("application/json", "utf-8", data)); } }; add(ajaxSaveBehaviour); String callBackURL= ajaxSaveBehaviour.getCallbackUrl().toString(); logger.info(" callback url :"+ callBackURL);
- How to handle jQuery.ajax(..) JSON request ?
- How to handle blocking clicks
- How to handle the pressure job
- MFC how to handle ocx event
- how to handle the office politics
- How To Handle Row Selection in UITableView
- Qt5: how to handle fonts when deploying?
- Selenium – How to handle WAIT
- How to handle big repositories with git
- How to handle Mongoose DB connection interruptions
- How to format a JavaScript date(jquery ,json ,日期)
- How to POST a django form with AJAX & jQuery
- How to parse JSON
- Ajax how to (2)
- how to performance better to handle multi-thread initialize
- how to study jquery
- Unable to handle kernel paging request at virtual address f600030a
- Unable to handle kernel paging request at virtual address
- wmi 查找BIOS信息
- 黑马程序员_Java高新技术——内省,注解
- 冒泡排序,快速排序,归并排序,选择排序,插入排序,堆排序
- 解决Oracle更改数据库表名报错
- 互联网 DBA 需要做那些事
- How to handle jQuery.ajax(..) JSON request ?
- Eclipse快捷键大全
- ubuntu更新源
- Linux script 命令记录(数据库)操作步骤
- 【数组与指针】如何在C/C++中动态分配二维数组
- Android中使用Post请求
- android应用启动页面
- RepositoryItemLookUpEdit编辑列如何输入新值
- stty命令使用