phpÖÐÓÃajaxÔõô·µ»Ø¶þάÊý¾Ý - PHP / »ù´¡±à³Ì
´ó¼ÒÈ¡¸öÀý×Ó°É
ʹÓÃjsonÊý¾Ý¸ñʽ
²»ÄÜÕâÑùµÄ£¬phpҪת»¯Îª xml »òÕß json £¬Ç°Ì¨Óà jsÀ´½âÊÍ
ÓÐʲô²å¼þûÓÐÄØ£¿
ÒÔǰÔÚJSPÀïÃæÓÃjsonrpc,дÂß¼º¯Êý¿ÉÒÔÖ±½Ó·µ»ØÊý×é
PHP code:
$arRet = array( "error" => false, array( 'user', 'pass' ) );
echo json_encode( $arRet );
ajax·µ»ØÊý¾ÝÓÐʲôÓÃÄØ£¿
ÄãÎʵÄÎÊÌâ²»¶Ô°É¡£
Ó¦¸ÃÊÇphpÔõô·µ»Øjson×Ö·û´Ü°É£¿
ajaxÒ»°ã¿ÉÒÔ´¦Àíhtml,jsonºÍxmlÈýÖÖÊý¾Ý£¬ÆäÖÐjsonÊÇ×î·½±ãʹÓõ쬹ØÓÚ´óÁ¿Êý¾Ýphp×îºÃ·Å»Øjson×Ö·û´Ü¡£
·½·¨1 ·µ»Øjson
·½·¨2 °ÑÄãÏëÒªÊä³öµÄÖ±½ÓÊä³ö³öÀ´¡£
¿Í»§¶Ë½ö×ö $('#id').html(data);
php ¶þ維數組.
PHP code:
$sql_table="SELECT t.table_id,t.opentable_id,t.table_number,t.table_name,t.table_layout_id,t.table_room_layout_id,t.table_sum,t.table_state,l.layout_name from `tables` as t left join layouts l on t.table_layout_id=l.layout_id $where order by t.table_id asc";
// echo $sql_table;
$result_tables=select($sql_table,$link);
$arry=array();
if($result_tables and mysql_num_rows($result_tables)>0)
{
while($rows=mysql_fetch_assoc($result_tables))
{
$table_id=$rows["table_id"];
$table_sum=$rows
Ïà¹ØÎÊ´ð£º
ÎÒÏÖÔÚÓÃstruts2¿ò¼Ü,ÐèҪʹÓÃajaxʵÏÖ¾Ö²¿Ë¢Ð£¬µ«ÊÇ´ÓÈÝÆ÷Àï·µ»ØµÄÖµ²»ÖªµÀÔõô´Óstruts.xmlÅäÖÃÎļþÀïÓ³Éäµ½jspÒ³ÃæÀÒÔǰservletÀïдout.orint("xxxxx")¾Í¿ÉÒԵõ½~£¬µ«ÊÇÏÖÔÚÓÃstruts¾Í²»ÖªµÀÔõôР......
<script language="javascript">
var XMLHttpReq;
var cont=true;
//´´½¨XMLHttpRequest¶ÔÏó
function createXMLHttpRequest ......
ÎÒJSPµÄÒ³ÃæÊÇ£º
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
1¡¢ÊDz»ÊÇPHPÖÐÖ»ÄÜʹÓÃmysql_query("update user_aa set money=money2-".$bpanmm." where uid=".$userppp);¸üÐÂÊý¾Ý£¿£¿£¿
2¡¢PHP¸üÐÂmysql_fetch_row($res)Óëmysql_fetch_array($res)ÖеÄÊý¾ ......