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

相关推荐