您好,登錄后才能下訂單哦!
$(document).ajaxSend(onSend); function onSend(e,xhr,o) { o.data=dataEncode(o.data); }; function htmlEncode (str){ var s = ""; if (str.length == 0) return ""; //s = str.replace(/ /g, " "); //s = str.replace(/&/g, "&"); s = str.replace(/</g, "%26lt%3B"); s=s.replace(/%3C/g,"%26lt%3B"); s=s.replace(/%3c/g,"%26lt%3B"); s = s.replace(/>/g, "%26gt%3B"); s = s.replace(/%3E/g, "%26gt%3B"); s = s.replace(/%3e/g, "%26gt%3B"); //s = s.replace(/\'/g, "'"); //s = s.replace(/\"/g, """); //s = s.replace(/\n/g, "<br>"); return s; }; function htmlEncodeOut (str){ var s = ""; if (str.length == 0) return ""; //s = str.replace(/ /g, " "); //s = str.replace(/&/g, "&"); s = str.replace(/</g, "<"); s=s.replace(/%3C/g,"<"); s=s.replace(/%3c/g,"<"); s = s.replace(/>/g, ">"); s = s.replace(/%3E/g, ">"); s = s.replace(/%3e/g, ">"); s = s.replace(/%26lt%3B/g, "<"); s = s.replace(/%26lt%3b/g, "<"); s = s.replace(/%26gt%3B/g, ">"); s = s.replace(/%26gt%3b/g, ">"); //s = s.replace(/\'/g, "'"); //s = s.replace(/\"/g, """); //s = s.replace(/\n/g, "<br>"); return s; }; function dataEncode(data){ var rel=data; var source=""; if(typeof(rel) == "object"){ source=htmlEncode(JSON.stringify(rel)); source=JSON.parse(source); rel=source; }else if(typeof(rel) == "string"){ source=htmlEncode(rel); rel=source; } return rel; }; function dataEncodeOut(data){ var rel=data; var source=""; if(typeof(rel) == "object"){ source=htmlEncodeOut(JSON.stringify(rel)); source=JSON.parse(source); rel=source; }else if(typeof(rel) == "string"){ source=htmlEncodeOut(rel); rel=source; } return rel; }; /* //此處的Ajax請求是一個示例;未使用框架封裝的Ajax請求時,這需要在自己的ajax方法的success函數的首行添加-- data=dataEncodeOut(data); jQuery.ajax({ type:"post", data:data, url:"http://dfh.smartcity.com/portal/app/service/App.getStateCatalogues.json", async:async, dataType:"json", success: function aa(data) { //需要首行添加 data=dataEncodeOut(data); alert("success已經收到:"+data); } });*/
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。