PHPºÍJavascriptµÄJSON½»»¥£¨´¦ÀíÒ»¸ö¶þάÊý×飩
PHPµÄJSONÀà¿âÎÒʹÓõÄÊÇServices_JSON
£¬Ã»Ê²Ã´ÌرðµÄÓŵ㣬ҲûʲôÃ÷ÏÔµÄȱµã£¬¶Ô¸¶ÓÃ×ãÒÓ¡£
½¨Á¢Îļþdata.php
£º
<?php
include(
"JSON.php"
);
$data
= array(
array(
'name'
=>
mb_convert_encoding
(
'ÀÏÍõ'
,
'UTF-8'
,
'GBK'
),
'age'
=>
'28'
),
array(
'name'
=>
mb_convert_encoding
(
'С»Æ'
,
'UTF-8'
,
'GBK'
),
'age'
=>
'27'
)
);
$json
= new
Services_JSON
();
echo
$json
->
encode
(
$data
)
;
?>
Javascript½âÎöJSONÎÒʹÓõÄÊÇJquery
£¬Ö±½ÓʹÓÃJavascriptµÄevalÔòÓиöµØ·½Òª×¢Ò⣺
var myObject = eval('(' + myJSONtext + ')');
¾ßÌå¿É²é¿´ÏÂÃæµÄ²Î¿¼Á´½Ó¡£
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>demo</title>
<script type="text/javascript" src="jquery-latest.pack.js"></script>
<script>
$(function(){
$.getJSON("data.php
", function(json){
for(var i = 0; i < json.length; i++)
{
alert("ÐÕÃû£º" + json[i].name);
alert("ÄêÁ䣺" + json[i].age);
}
});
});
</script>
</head>
<body>
</body>
</html>
²Î¿¼×ÊÁÏ£ºhttp://www.json.org/js.html
Ïà¹ØÎĵµ£º
/**
* CSSClass.js
*/
var CSSClass = {}; //Create our namespace object
//Return tru if element e is a member of the class c;false otherwise
CSSClass.is = fucntion(e, c)
{
if(typeof e == "string")
e = document.getElementById(e);
//Before doing a regexp search,optimize for couple of co ......
½ñÌì¿´µ½Í¬ÊÂharry_duanдµÄÒ»¸öjsÎļþ£¬¸Ð¾õͦÓÐÒâ˼¡£
Ä¿µØÊÇÔÚjsÎļþÖÐʹÓÃjstlµÄfmt:message
1.ÔÚ×ÊÔ´ÎļþÖж¨ÒåÏûÏ¢ errors.message1=error xxxxxx
2.´´½¨Ò»¸öjsÎļþ£¬ÎªÁËjstlÄÜÓ㬽«jsÎļþÃüÃûΪ myjs.js.jsp (ÒÔjsp½áβ)
js ´úÂë
<%@ page contentType="text/html; charset=utf-8 ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)> <td>no </table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡Ïûѡȡ¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false&quo ......
IE7²»¾Ìáʾ¹Ø±Õä¯ÀÀÆ÷´°¿Ú
<a href="javascript:window.open('','_top'); window.top.close();">Close IE7</a>
----------------------------
ÓÃwindow.open·½·¨´ò¿ªÐ´°¿ÚÏÔʾÌáʾÐÅÏ¢
ÓÐʱºòÎÒÃÇÐèÒª´ò¿ªÒ»¸öд°¿ÚÓÃÀ´ÏÔʾÌáʾÐÅÏ¢
Õâ¸ö×ÔÈ»»áÏëµ½ÓÃwindow.open()·½·¨
µ«Ð´°Ì ......
ÕûÀí×Ô£ºhttp://bbs.phpchina.com/viewthread.php?tid=18006
Îļþa.txt£¬ÓÃPHPÈçºÎÅжÏËüµÄ±àÂëÊÇGBK»¹ÊÇUTF-8ÄØ£¿
1£¬ÖØÐÂÈÏʶһÏ´ËÎÊÌ⣬µ±Ê±°æÖ÷»Ø¸´µÄʱºòÎҾ;õµÃmbº¯ÊýÀïÒ»¶¨ÓÐÕâÑùµÄ¹¦ÄÜ£¬µ«½ñÈÕÑо¿ÁËmb¿â£¬²¢Ã»ÓÐÕâÑùµÄ¹¦ÄÜ¡£ÓÃmb_detect_encoding×ÜÊDz»×¼È·¡£
echo mb_detect_encoding(file_get_conten ......