ajax设置

前端之家收集整理的这篇文章主要介绍了ajax设置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
function ajaxFun(props){
	var url=props.url;
	var data=props.data;
	var success=props.success;
	$.ajax({
		        url:url,type:"POST",cache:false,contentType:"application/json;charset=utf-8",data:mycomm_ascii2native(JSON.stringify(data)),dataType:"json",processData:false,beforeSend:function(request){
				request.setRequestHeader("xxx","xxx");
			},success:function(obj){
				
			},error:function(request,textStatus,errorThrown){
				
			},complete:function(){	
			}	
	});
}

//native2ascii
function mycomm_native2ascii(n){
     var regexp=/[^\x00-\xff]/g;
     var a=n;
     while(m=regexp.exec(n)){
         a=a.split(m[0]).join(escape(m[0]).split("%").join("\\"));
     }
     return a;
 }

//ascii2native    
function mycomm_ascii2native(a) {
    var n=a;
    var n=unescape(n.split("\\").join("%"));
    return n;
}
原文链接:https://www.f2er.com/ajax/165736.html

猜你在找的Ajax相关文章