校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > AJAX 異步傳輸數據的問題

AJAX 異步傳輸數據的問題

熱門標簽:電銷機器人違法了嗎 遼寧銀行智能外呼系統 姜堰電銷機器人 海南銀行智能外呼系統商家 遼寧正規電銷機器人 澳大利亞城市地圖標注 許昌智能電銷機器人公司 辰溪地圖標注 上海浦東騰訊地圖標注位置
要異步傳輸的數據:
Xml代碼
....
action xsi:type="basic:JavaScript" script="index += 1;"/>
....
Ajax異步傳輸代碼:
Js代碼
復制代碼 代碼如下:

var postData = "input="+ escape(inputJSON) +"script="+escape(xml)+
"feedGeneral=" + escape(feedGeneral);
XmlHttpRequest.open("POST",url,true);
XmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
XmlHttpRequest.send(postData);

postData在encode和unencode,最終導致在后臺Servlet中得到得到數據+被空格代替,使得script中的index += 1;變成了index = 1;從而導致后臺Java代碼在跑script出現死循環。
在網上搜索,發現content-type使用application/x-www-form-urlencoded后:
[來自http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1]寫道
復制代碼 代碼如下:

Control names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as
described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal
digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').

然而使用form來提交方式來發起request卻不會出現類似的問題,而form默認的Content-Type也是application/x-www-form-urlencoded:
Js代碼
復制代碼 代碼如下:

$('test').innerHTML = "form target='_blank' id='test_form' action='./gen_feed' method='post'>"
+ "input type='text' name='input' />input type='text' name='script' />"
+ "input type='text' name='feedGeneral' />input type='hidden' name='format' value='" + this.feed_type + "'
/>"
+ "input type='submit' value='gen' />/form>";
var test_form = $('test_form');
test_form.elements[0].value = inputJSON;
test_form.elements[1].value = script;
test_form.elements[2].value = feedGeneral;
test_form.submit();

仍未發現問題到底出在何處,暫做備忘。暫時把script中的‘+'都用‘-'代替,index += 1;改成index -= -1;呵呵,以后有人看到這段自動生成的詭異腳本,不知道會作何感想,但現在也只能如此。
您可能感興趣的文章:
  • ajax.js里面有內容顯示效果,根據ID
  • asp.net下 jquery jason 高效傳輸數據
  • 基于Jquery的跨域傳輸數據(JSONP)
  • JavaScript使表單中的內容顯示在屏幕上的方法
  • JS實現左右拖動改變內容顯示區域大小的方法
  • java編程實現基于UDP協議傳輸數據的方法
  • Python爬蟲抓取手機APP的傳輸數據
  • js實現內容顯示并使用json傳輸數據

標簽:晉城 伊春 撫州 西藏 崇左 威海 銅川 深圳

巨人網絡通訊聲明:本文標題《AJAX 異步傳輸數據的問題》,本文關鍵詞  AJAX,異步,傳輸,數據,的,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《AJAX 異步傳輸數據的問題》相關的同類信息!
  • 本頁收集關于AJAX 異步傳輸數據的問題的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 日喀则市| 增城市| 铜梁县| 炎陵县| 波密县| 福州市| 宜君县| 全椒县| 逊克县| 墨江| 鸡东县| 郁南县| 宝丰县| 图们市| 临洮县| 阿城市| 东莞市| 古丈县| 通河县| 浪卡子县| 赤壁市| 沅陵县| 神农架林区| 虹口区| 漾濞| 凉城县| 涟水县| 黔西县| 平安县| 普兰县| 柳州市| 尼木县| 吉木乃县| 佛冈县| 渝北区| 临海市| 鸡泽县| 南投县| 定兴县| 嵩明县| 衡水市|