1)发送路径中的参数有中文,在服务器端接收参数值是乱码
解决方法:
PHP:
服务器端:iconv("UTF-8","gb2312",$_POST[变量名]);
JSP:
客户端:
利用javascript的提供的escape()或encodeURI()方法, 例
var url="a.jsp?name=小李";
url=encodeURI(url);
url=encodeURI(url); //两次,很关键[具体为什么,我也不清楚]
/********************************************/
也有人写成var url="a.jsp?name=escape("小李")";
功能和encodeURI方法类似。
/********************************************/
xmlHTTP.setrequestheader("contentType","text/html;charset=uft-8")//指定发送数据的编码格式
服务器端:java.net.URLDecoder.decode(request.getParameter(变量名), "UTF-8");
2)返回来的responseText或responseXML的值中含有中文是乱码
原因:AJAX在接收responseText或responseXML的值的时候是按照UTF-8的格式来解码的,如果服务器段发送的数据不是UTF-8的格式,那么接收responseText或responseXML的值有可能为乱码。
解决方法:在服务器端指明送出数据的编码流
PHP:header('Content-Type:text/html;charset=GB2312');
ASP:Response.Charset("GB2312")
......
AJAX自从引进了Tab,着实让我开心了一番。但是,在调整Tab的样式的时候,也着实让我吃了一惊。
于是,抱着没有困难也要制造困难的原则,开始了征途:
按照Tab作者Ronald Buckton所说,Tab的CSS包含如下几个类:
(1).ajax__tab_header: A container element that wraps all of the tabs at the top of the TabContainer.
(2).ajax__tab_outer:An outer element of a tab,often used to set the left-side background image of the tab.
(3).ajax__tab_inner:An inner element of a tab,often used to set the right-side image of the tab.
(4).ajax__tab_tab:An element of a tab that contains the text content.
(5).ajax__tab_body:A container element that wraps the area where a TabPanel is displayed.
(6).ajax__tab_hover:This is applied to a tab when the mouse is hovering over.
(7).ajax__tab_active:This is applied to a tab when it is the currently selected tab.
我画了个简图,当然,鼠标放上去(.ajax__tab_hover),和当前Tab(.ajax__tab_active)的那个就没画上去。
层次关系如图所示,弄清楚这个层次关系,对设计Tab样式有很大帮助。 ......
AJAX自从引进了Tab,着实让我开心了一番。但是,在调整Tab的样式的时候,也着实让我吃了一惊。
于是,抱着没有困难也要制造困难的原则,开始了征途:
按照Tab作者Ronald Buckton所说,Tab的CSS包含如下几个类:
(1).ajax__tab_header: A container element that wraps all of the tabs at the top of the TabContainer.
(2).ajax__tab_outer:An outer element of a tab,often used to set the left-side background image of the tab.
(3).ajax__tab_inner:An inner element of a tab,often used to set the right-side image of the tab.
(4).ajax__tab_tab:An element of a tab that contains the text content.
(5).ajax__tab_body:A container element that wraps the area where a TabPanel is displayed.
(6).ajax__tab_hover:This is applied to a tab when the mouse is hovering over.
(7).ajax__tab_active:This is applied to a tab when it is the currently selected tab.
我画了个简图,当然,鼠标放上去(.ajax__tab_hover),和当前Tab(.ajax__tab_active)的那个就没画上去。
层次关系如图所示,弄清楚这个层次关系,对设计Tab样式有很大帮助。 ......
用Ajax实现Tab效果的
先创建
ajax.php,在其中输入如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample 2_1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
<!--
//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp = false;
//Check if we are using IE.
function creatXMLHttp(){
try
{
//If the Javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer.");
}
catch (e)
{
//If not, then use the older active x object.
try
{
//If we are using Internet Explorer.
xmlhttp = new ......
用Ajax实现Tab效果的
先创建
ajax.php,在其中输入如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample 2_1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
<!--
//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp = false;
//Check if we are using IE.
function creatXMLHttp(){
try
{
//If the Javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer.");
}
catch (e)
{
//If not, then use the older active x object.
try
{
//If we are using Internet Explorer.
xmlhttp = new ......
如上图所示为Accordion控件:
感觉不错的样式
<style type="text/css">
.headerBg{cursor:hand;text-align:center;width:180px;height:21px;background-image:url(images/ajaxmenubg1.gif);FONT-SIZE: 12px;line-height:21px;}
.contentBg{width:180px;text-align:left;BACKGROUND-COLOR: #D1ECC8; FONT-SIZE: 12px; Font-color: #669900; FONT-FAMILY: "宋体"}
</style>
</head>
一、静态加载:
页面代码如下:
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:Accordion ID="Accordion1" runat="server" Height="329px" Width="198px"
HeaderCssClass ="accordionHeader"
ContentCssClass ="accordionContent"
FadeTransitions ="true"
TransitionDuration ="300"
FramesPerSec ......
jQuery学习笔记
提交form表单之后,不会刷新页面,而是局部刷新,欲提交的form只要有id即可
如果使用get请求,注意中文乱码问题,jquery会先使用iso8859-1解码,然后发给服务器,如果使用post请求,则直接将中文内容提交给服务器解析。
使用jquery-1.4.2.js和jquery.form.js插件。
如果创建新的js文件中,需要加上
document.write("<script type='text/javascript' src='jquery-1.4.2.js'></script>")
document.write("<script type='text/javascript' src='jquery.form.js'></script>")
// 动态加载页面
// id 显示页面的容器组件ID2
// url 欲加载页面网址
// gop get请求还是post请求,默认get
function loadPage(id, url, gop) {
$("#" + id).addClass("loader");
$("#" + id).append("Loading......");
var type = (gop == "post" ? "post" : "get");
$.ajax( {
type : type,
url : url,
cache : false,
error : function() {
alert('加载页面' + url + '时出错!')
},
success : function(content) {
$("#" + id).empty().append(content);
$("#" + id).removeClass("loader");
}
......
如上图所示的等级控件(这个控件主要指定样式):
页面代码:
<head runat="server">
<title>无标题页</title>
<mce:style type ="text/css"><!--
.ratingStar
{
font-size:0pt;
width:15px;
height:12px;
padding:1px;
margin:1px;
cursor:pointer;
display:block;
background-repeat:no-repeat;
background-color:#99CC99;
}
.filledRatingStar
{
background-image:url(image/star1.gif);
}
.emptyRatingStar
{
background-image:url(image/star2.gif);
}
.savedRatingStar
{
background-image:url(image/star3.gif);
}
--></mce:style><style type ="text/css" mce_bogus="1"> .ratingStar
{
font-size:0pt;
width:15px;
height:12px;
padding:1 ......