jquery ajaxµÄ $.get()ºÍ$.post()·½·¨
$.get()ºÍ$.post()·½·¨
$.get(url [,data] [,callback] [,type])
type£ºstringÀàÐÍ£¬·þÎñÆ÷¶Ë·µ»ØÄÚÈݵĸñʽ£¬°üÀ¨xml£¬html£¬script£¬json£¬textºÍ_default
»Øµ÷º¯ÊýÖ»ÓÐÁ½¸ö²ÎÊý£ºfunction(data,textstatus){....}
data:·µ»ØµÄÄÚÈÝ £» textstatusÇëÇó״̬£ºsuccess£¬error£¬notmodified£¬timeout 4ÖÖ
Èç¹ûÆÚ´ý·þÎñÆ÷¶Ë·µ»ØµÄÊý¾Ý¸ñʽÊÇXMLÎĵµ£¬ÄÇôÐèÒªÔÚ·þÎñ¶ËÉèÖÃcontent-typeÀàÐÍ£º
php´úÂ룺header("Content-type:text/xml; charset=utf-8");
$.postÓë$.get()µÄ½á¹¹ºÍʹÓ÷½Ê½Ïàͬ
Çø±ð£º
·getÇëÇó»á½«²ÎÊý¸úÔÚurlºó½øÐд«µÝ£¬¶øpostÇëÇóÔòÊÇ×÷ΪhttpÏûÏ¢µÄʵÌåÄÚÈÝ·¢Ë͸øweb·þÎñÆ÷¡£
·get·½Ê½¶Ô´«ÊäÊý¾ÝÓдóСÏÞÖÆ£¨Í¨³£²»ÄÜ´óÓÚ2KB£©£¬postÀíÂÛÉϲ»ÊÜÏÞÖÆ
·get·½Ê½ÇëÇóµÄÊý¾Ý»á±»ä¯ÀÀÆ÷»º´æÆðÀ´£¬ÆäËûÈË¿ÉÒÔ´ÓÀúÊ·¼Ç¼Àï¶ÁÈ¡ÕâЩÊý¾Ý£¬ÈçÕ˺ŵȡ£get·½Ê½»á´øÀ´ÑÏÖصݲȫÎÊÌâ¡£post¿ÉÒÔ±ÜÃâÕâЩÎÊÌâ¡£
·getºÍpost·½Ê½´«µÝµÄÊý¾ÝÔÚ·þÎñÆ÷¶ËµÄ»ñÈ¡Ò²²»Í¬¡£
Ïà¹ØÎĵµ£º
ÓÃstruts2+jquery+json+hibernate+ajax×öÁËÒ»¸öµÇ½µÄdemo¡£
1.jspÒ³Ãæ
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/x ......
Client¶Ë
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="javascript">
var XmlHttp=new ActiveXObject("Microsoft.XMLhttp");
function sendAJAX()
{
&nb ......
×¢Ò⣺$.get()ºÍ$.post()·½·¨ÊÇjQueryÖеÄÈ«¾Öº¯Êý¡£Ç°Ãæ½²µ½µÄload()·½Ê½ÊǶÔjQuery¶ÔÏó½øÐвÙ×÷µÄ¡£
1¡¢ $.get()·½·¨
¡¡¡¡$.get()·½·¨Ê¹ÓÃGET·½Ê½À´½øÐÐÒì²½ÇëÇó¡£
¡¡¡¡ËüµÄÓï·¨½á¹¹Îª£º
¡¡¡¡$.get( url [, data] [, callback] [, type] )
¡¡¡¡$.get()·½·¨²ÎÊý½âÊÍÈçÏÂ±í£º
²ÎÊýÃû³Æ
Àà¡¡ÐÍ
˵¡¡¡¡Ã÷
url
Strin ......
×òÌì¿´ÁËƪ²»ÊǺÜÑϽ÷µÄ²©ÎÄ¡¶Ò»¸öËãÃüС͵³ÌÐòµÄµ®Éú¡·£¬ÀïÃæдÁËÒ»¸öͨ¹ýAJAX͵ÇÔ±ðÈËÍøÕ¾Ëã·¨µÄ·½·¨¡£Êµ¼ùÁËһϸù±¾²»ÐУ¬AJAXËƺõ²»ÄÜ¿çÓò¡£
ºóÀ´ÎÒÏëÁËһЩ½â¾ö·½·¨£¬ÖÕÓÚ¿çÓò³É¹¦¡£ÏÖÔÚ¹«²¼Ò»Ï·½·¨¡£
ÈÎÎñ£ºÔÚ×Ô¼ºÍøÕ¾×ö¸ö±íµ¥£¬Ïò¡ ......