Jquery ajax ³õ̽
³õѧJQUERY AJAXʹÓ㬲»ÖªµÀÔõôʵÏÖ£¬ÕÒÁ˰ëÌì×ÊÁ϶¼²î²»¶à£¬¿ÉÊǷŵ½ÎÒµÄÒ³ÃæÀï¾ÍÊDz»·µ»ØÖµ£¬ºóÀ´·¢ÏÖÒòΪûÍùºóÌ¨Ò³Ãæ´«ÖµµÄÔÒò£¬¼ÓÁË data: "name=John&location=Boston"¾ÍºÃÓÃÁË£¬ÕâÀïdata:""¿ÉΪÈÎÒâÖµ£¬ºǫ́²¢Ã»ÓнÓÊÕ¡£
ÏÂÃæÊÇÀý×Ó£¬ÊµÏÖµÄÊÇ»ñÈ¡·þÎñÆ÷ʱ¼ä²¢¸üÐÂ
ǰ̨´úÂ룺
function getServerTime()
{
$.ajax({
type: "POST",
url: "Default2.aspx",
data: "name=John&location=Boston",
success: function(msg){
$("#txtserver").text(msg);
}
});
setTimeout('getServerTime()',500);
}
ǰ̨´úÂë2£ºÊ¹ÓÃPost·½·¨
function getServerTime()
{
$.get("Default2.aspx?1",function(msg){
$("#txtserver").text(msg);});
setTimeout('getServerTime()',500);
}
ºǫ́Default2.aspx
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(DateTime.Now.ToLongTimeString());
}
Ïà¹ØÎĵµ£º
Ò»¸ö¼òµ¥ajax repeater·ÖÒ³demo ¸Ä½ø°æ. ´úÂëÈçÏÂ..
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(0)">1</a>
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(1)">2< ......
ʲôÊÇ AJAX?
¡¡¡¡AJAX (Òì²½ JavaScript ºÍ XML) ÊǸöвúÉúµÄÊõÓï,רΪÃèÊöJavaScriptµÄÁ½ÏîÇ¿´óÐÔÄÜ.ÕâÁ½ÏîÐÔÄÜÔÚ¶àÄêÀ´Ò»Ö±±»ÍøÂ翪·¢ÕßËùºöÂÔ,Ö±µ½×î½üGmail, Google suggestºÍgoogle MapsµÄºá¿Õ³öÊÀ²ÅʹÈËÃÇ¿ªÊ¼Òâʶµ½ÆäÖØÒªÐÔ.
¡¡¡¡ÕâÁ½Ïî±»ºöÊÓµÄÐÔÄÜÊÇ:
¡¡¡¡ÎÞÐèÖØÐÂ×°ÔØÕû¸öÒ³Ãæ±ãÄÜÏò·þÎñÆ÷·¢ËÍÇëÇó.
¡¡¡ ......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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 runat=" ......
ÍêÈ«ÊÊÓÃASP.NETµÄÈÏÖ¤»úÖÆ
–¿ÉÒÔʹÓÃFormsAuthentication
•WebService·½·¨¿ÉÒÔ²Ù×÷Cookie
–Impersonation
–PrincipalPermission
WebService7.cs Code
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
usi ......
$(function(){
new AjaxUpload('file1', {
action: 'uploadpic.asp',
name: 'form1',
data:{act:'uploadfile',FormName:'form1'},
autoSubmit:false,
responseType:'json',
onSubmit:function(file,ext){
if (!(ext && /^(jpg|png|gif)$/i.test(ext))){
alert('ÇëÄúÉÏ´« ......