- 浏览: 1160032 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (411)
- Java Foundation (41)
- AI/机器学习/数据挖掘/模式识别/自然语言处理/信息检索 (2)
- 云计算/NoSQL/数据分析 (11)
- Linux (13)
- Open Source (12)
- J2EE (52)
- Data Structures (4)
- other (10)
- Dev Error (41)
- Ajax/JS/JSP/HTML5 (47)
- Oracle (68)
- FLEX (19)
- Tools (19)
- 设计模式 (4)
- Database (12)
- SQL Server (9)
- 例子程序 (4)
- mysql (2)
- Web Services (4)
- 面试 (8)
- 嵌入式/移动开发 (18)
- 软件工程/UML (15)
- C/C++ (7)
- 架构Architecture/分布式Distributed (1)
最新评论
-
a535114641:
LZ你好, 用了这个方法后子页面里的JS方法就全不能用了呀
页面局部刷新的两种方式:form+iframe 和 ajax -
di1984HIT:
学习了,真不错,做个记号啊
Machine Learning -
赵师傅临死前:
我一台老机器,myeclipse9 + FB3.5 可以正常使 ...
myeclipse 10 安装 flash builder 4.6 -
Wu_Jiang:
触发时间在将来的某个时间 但是第一次触发的时间超出了失效时间, ...
Based on configured schedule, the given trigger will never fire. -
cylove007:
找了好久,顶你
Editable Select 可编辑select
1 使用form做提交,target设为iframe的name:
2 使用ajax。以div域的局部刷新为例,假设页面中有
birt结合ajax做报表区域局部刷新的例子:
http://www.roseindia.net/answers/viewanswers/1936.html
Q & A:Div as Form Target,Possible?
Q:
关于ajax乱码问题:
使用以下代码,传给birt的中文省名provinceName老是乱码:
后改成通过XmlHttpRequest的send方法来传参,解决了这个乱码问题:
貌似得出的结论就是:
如果使用ajax做中文参数的传递,不要在url中做中文参数的追加,使用XmlHttpRequest.send(参数串)来传参,参数串里的中文就不会乱码。
引用
<iframe name="info" id="info" frameborder="0" src="" scrolling="no" width="100%" height="1000"></iframe>
<form id="mapForm" name="mapForm" action="" method="post" [b]target="info"[/b]>
2 使用ajax。以div域的局部刷新为例,假设页面中有
<div id="mapDiv" name="mapDiv">,在ajax的回调方法中,使用document.getElementById("mapDiv").innerHTML =xmlhttp.responseText即可实现该div区域的局部刷新。
birt结合ajax做报表区域局部刷新的例子:
http://www.roseindia.net/answers/viewanswers/1936.html
var xmlhttp = new getXMLObject(); function 调用ajax的函数() { if(xmlhttp) { //URL中带中文不行,故通过xmlhttp的send(params)来传递(中文)参数 //var url = "<%=request.getContextPath()%>/preview?__report=rptfiles/tuition_map.rptdesign&startDate=${startDate}&endDate=${endDate}&province=" + encodeURIComponent(provinceName); var url = "<%=request.getContextPath()%>/preview"; var params = "__report=rptfiles/tuition_map.rptdesign&startDate=${startDate}&endDate=${endDate}&province=" + provinceName; //alert(url); //alert(params); xmlhttp.open("POST",url,true); xmlhttp.onreadystatechange = handleServerResponse; xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); xmlhttp.send(params); } } //XML OBJECT function getXMLObject() { var xmlHttp = false; try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") // For Old Microsoft Browsers } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") // For Microsoft IE 6.0+ } catch (e2) { xmlHttp = false // No Browser accepts the XMLHTTP Object then false } } if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); //For Mozilla, Opera Browsers } return xmlHttp; // Mandatory Statement returning the ajax object created } function handleServerResponse() { if (xmlhttp.readyState == 4) { //if(xmlhttp.status == 200) { //alert(xmlhttp.responseText); document.getElementById("mapDiv").innerHTML =xmlhttp.responseText; //} // else { // alert("Error during AJAX call. Please try again"); // } } }
Q & A:Div as Form Target,Possible?
Q:
引用
Does anyone know how to target a <DIV...>. I want to put an HTML form
in a DIV. When it's submitted, the results should show up within that
same DIV. Possible?
A:in a DIV. When it's submitted, the results should show up within that
same DIV. Possible?
引用
You can't target a div the way you can a frame;
you'd have to use AJAX techniques: have a button that triggers,
instead of a form submission, a call to a JavaScript function that
manually assembles and POSTs the same query that the browser would
assemble if you had really submitted the form, with a callback to a
JavaScript function that populates the div with the results. There
are JavaScript libraries that make this task easier (dojo, Yahoo!,
etc), but you still need to know how to program...
you'd have to use AJAX techniques: have a button that triggers,
instead of a form submission, a call to a JavaScript function that
manually assembles and POSTs the same query that the browser would
assemble if you had really submitted the form, with a callback to a
JavaScript function that populates the div with the results. There
are JavaScript libraries that make this task easier (dojo, Yahoo!,
etc), but you still need to know how to program...
关于ajax乱码问题:
使用以下代码,传给birt的中文省名provinceName老是乱码:
var url = "<%=request.getContextPath()%>/preview?__report=rptfiles/tuition_map.rptdesign&startDate=${startDate}&endDate=${endDate}&province=" + provinceName; xmlhttp.open("POST",url,true); xmlhttp.onreadystatechange = 回调函数的名字; xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); xmlhttp.send(null);使用什么escape() encodeURI() encodeURIComponent()对url中的中文provinceName做转化都无法解决问题;
后改成通过XmlHttpRequest的send方法来传参,解决了这个乱码问题:
var url = "<%=request.getContextPath()%>/preview"; var params = "__report=rptfiles/tuition_map.rptdesign&startDate=${startDate}&endDate=${endDate}&province=" + provinceName; xmlhttp.open("POST",url,true); xmlhttp.onreadystatechange = 回调函数的名字; xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); xmlhttp.send(params);
貌似得出的结论就是:
如果使用ajax做中文参数的传递,不要在url中做中文参数的追加,使用XmlHttpRequest.send(参数串)来传参,参数串里的中文就不会乱码。
发表评论
-
页面嵌入声音
2011-06-27 20:17 1263几个选择: embed标签 bgsound标签 objec ... -
DHTMLX
2011-05-13 09:53 2397通过 Access IFRAME Content 实现 dht ... -
ajax:Add exception message to json response
2011-05-06 10:07 1938Add exception message to json r ... -
W3C DOM 之 (nodeName || tagName) && nodeType && nodeValue
2010-11-21 16:34 1284tagName和nodeName的区别 http://blog ... -
Js之appendChild() insertBefore() 和扩展的 insertAfter()
2010-11-21 16:14 2995JavaScript之appendChild、insertBe ... -
Extending js Array Prototype
2010-08-11 16:55 1293Extending array prototype with ... -
parentNode与parentElement区别 childNodes与children区别
2010-08-11 11:47 2848parentElement and children is f ... -
readonly和Disabled的区别;display:none和visible:hidden的区别
2010-07-29 11:59 4031Readonly和Disabled: http://www.c ... -
Editable Select 可编辑select
2010-03-30 18:58 7277极棒的一段Editale Select代码: http://w ... -
多用try catch做js调试
2010-03-27 15:00 2414碰到莫名其妙的js错误,多用try catch做调试! 在调 ... -
当onblur遇到focus()
2010-03-19 13:46 2097当onblur触发的function中使用了aElement. ... -
URL中文乱码问题
2010-01-22 00:19 1999解决办法: 一 使用form做提交 二 前台jsp页面编码方 ... -
frame,iframe,frameset之间的关系与区别
2009-11-12 15:11 1847http://www.cnblogs.com/wennxxin ... -
使用JS刷新showModalDialog窗口
2009-09-26 21:28 3722http://midnightair.iteye.com/bl ... -
getElementsByName无法获得Div
2009-09-20 14:40 2837<input name="test" ... -
js 去掉html标记 去掉换行
2009-09-16 20:15 2754mymsg=mymsg.replace(/<\/?. ... -
document.getElementById为空或不是对象的解决方法
2009-09-11 09:32 4315在使用document.getElementById时,遇到个 ... -
十大JavaScript函数 Top 10 custom JavaScript functions
2009-09-03 22:38 2072http://www.dustindiaz.com/basem ... -
关于js 中的 $()
2009-09-03 21:22 2083并不是js的什么特殊用法。其实只是你的页面引用到的js(或被i ... -
DIV Alert
2009-09-03 19:22 1118透明的DIV提示框 http://www.cnblogs.co ...
相关推荐
实现无刷新提交表单的技术主要有Ajax和iframe两种方式。 首先,Ajax(Asynchronous JavaScript and XML)技术的核心是通过JavaScript发起异步网络请求,与服务器进行数据交换,而后通过DOM操作更新页面的局部内容,...
AJAX(Asynchronous JavaScript and XML)提交和FORM提交是两种常见的网页数据提交方式,它们各自具有不同的特性和适用场景。 1. **AJAX提交** - **异步性**:AJAX的最大特点是异步,它可以在不刷新整个页面的情况...
-删除Panel的EnableLightBackgroundColor属性,同时EnableBackgroundColor只支持Blue和Gray两种Theme。 +2010-01-31 v2.2.0 -使得Asp.net的控件ImageButton具有和Asp.net的Button控件类似的行为(Ajax提交)...
-删除Panel的EnableLightBackgroundColor属性,同时EnableBackgroundColor只支持Blue和Gray两种Theme。 +2010-01-31 v2.2.0 -使得Asp.net的控件ImageButton具有和Asp.net的Button控件类似的行为(Ajax提交)...
通过使用iframe,可以在页面中嵌入另一个页面,从而实现局部刷新的效果,常用于图片上传等场景。 ### JavaScript JQuery框架使用 jQuery是一个快速、简洁的JavaScript库,简化了HTML文档遍历、事件处理、动画以及...
此外,HTML可以与其他技术结合,例如通过AJAX(Asynchronous JavaScript and XML)异步获取数据,实现页面的局部刷新;与WebSocket配合实现双向通信,打造实时应用;还可以通过Web存储(localStorage和...
• sample03.htm 局部变量的使用方式 • sample04.htm 在函数体中定义全局变量 • sample05.htm 使用没有定义的变量 • sample06.htm 重复定义变量 • sample07.htm 引用未...