首页 > 其他分享 >dojo ajax 方法参数讲解 dojo.xhrPost

dojo ajax 方法参数讲解 dojo.xhrPost

时间:2022-11-19 19:02:03浏览次数:57  
标签:function dojo request ajax error type response xhrPost

field type description
content: Object Contains properties with string values. These properties will be serialized as name1=value2 and passed in the request.

error Function: function(response, ioArgs){} response is of type Object, ioArgs is of type dojo.__IoCallbackArgs. This function will be called when the request fails due to a network or server error, the url is invalid, etc. It will also be called if the load or handle callback throws an exception, unless djConfig.debugAtAllCosts is true. This allows deployed applications to continue to run even when a logic error happens in the callback, while making it easier to troubleshoot while in debug mode.

form : DOMNode DOM node for a form. Used to extract the form values and send to the server.

handle Function : function(response, ioArgs){} response is of type Object, ioArgs is of type dojo.__IoCallbackArgs. This function will be called at the end of every request, whether or not an error occurs.

handleAs : String Acceptable values are: text (default), json, json-comment-optional, json-comment-filtered, javascript, xml

headers : Object Additional HTTP headers to send in the request.

load Function : function(response, ioArgs){} response is of type Object, ioArgs is of type dojo.__IoCallbackArgs. This function will be called on a successful HTTP response code.

preventCache : Boolean Default is false. If true, then a "dojo.preventCache" parameter is sent in the request with a value that changes with each request (timestamp). Useful only with GET-type requests.

sync : Boolean false is default. Indicates whether the request should be a synchronous (blocking) request.

timeout : Integer Milliseconds to wait for the response. If this time passes, the then error callbacks are called.

url : String URL to server endpoint.

======================

base = {
ajax : function(formObj,datas){
var loader = {
handleAs:"text",
content:datas,
handle:function(resp){
try{
if(resp instanceof Error){
alert(resp);
}else{
alert(resp);
}
}catch(e){
}
},
error:function(error){
alert(resp);
},
sync: false
};
loader.form = formObj;
dojo.xhrPost(loader);
},
submit: function(formId){
alert(formId);
var formObj = dojo.byId(formId);
var datas = {age:20};
this.ajax(formObj,datas);
}
}
====================
当参数中有formObject对象时 可以不需要设置 url,
如果content中有参数,但是form表单中也有参数,则将formObject中的给屏蔽掉,使用content中的,但是对于url中的比如:?a=1 这样的是追加的方式处理
比如form表单中也有 input a = '2',这时传到后台后能够得到两个

标签:function,dojo,request,ajax,error,type,response,xhrPost
From: https://blog.51cto.com/u_15458282/5870603

相关文章

  • jQuery ajax上传文件
    <script>varformData=newFormData();constdate=$("#datepicker2").val();formData.append("date",date);formData.append("file",$("#upload")[0].f......
  • 25.JQury Ajax
    使用方法用菜鸟在线编辑器,不能允许跨站访问,不能从百度跳到谷歌getpostAJAXget......
  • ajax个人信息案例
    案例分析:如图所示,页面加载时有数据回填,同时实现select表单同步和图片上传,保存后上传至服务器等功能HTML模板:<!DOCTYPEhtml><htmllang="en"><head><metachars......
  • 19.Ajax
    概述在搜索框输入返回的结果就是ajax......
  • AJAX-基础步骤
          发送AJAX get请求:第一步:创建AJAX核心XMLHttpRequest对象varxhr=newXMLHttpRequest 第二步:注册回调函数;onreadystatechange是一个回调函......
  • vue中的ajax
    vue中的ajaxvue脚手架配置代理方法一​ 在vue.config.js中添加如下配置:devServer:{proxy:"http://localhost:5000"}说明:优点:配置简单,请求资源时直接发给前端(80......
  • jQuery中的Ajax
    1、了解jQuery中的Ajax (1)、      (2)、    (3)、$.ajax()的使用较广泛  ......
  • Flask框架:如何运用Ajax轮询动态绘图
    本文分享自华为云社区《​​Flask框架:运用Ajax轮询动态绘图​​》,作者:LyShark。Ajax是异步JavaScript和XML可用于前后端交互,在之前​​《Flask框架:运用Ajax实现数据交互》......
  • 8.Ajax研究(2)
    6.SpringMVC实现Ajax。1.实体类User@Data@AllArgsConstructor@NoArgsConstructorpublicclassUser{privateintage;privateStringname;privateS......
  • Ajax从入门到精通
    #三句话让AJAX为我欲罢不能大家好,我是精通AJAX的猿类高质量雄性码农,三句话让AJAX为我欲罢不能什么是AJAX?为什么要AJAX?怎么AJAX?下面就带着这三句话,来一起......