Ò»¡¢jquery+ajaxÒì²½Ìá½»±íµ¥
1.ʹÓÃpostÌá½»·½Ê½
2.¹¹Ôì±íµ¥µÄÊý¸ñʽ
3.½áºÏform±íµ¥µÄsubmitµ÷ÓÃajaxµÄ»Øµ÷º¯Êý¡£
ʹÓà jQuery Òì²½Ìá½»±íµ¥´úÂ룺
<html xmlns="">
<head>
<title>jqueryÒì²½Ìá½»±íµ¥-php×ÔѧÍø</title>
</head>
<script src=""></script>
<script>
jQuery(function($) {
// ʹÓà jQuery Òì²½Ìá½»±íµ¥
$('#f1').submit(function() {
$.ajax({
url: 'ta.aspx',
data: $('#f1').serialize(),
type: "post",
cache : false,
success: function(data)
{alert(data);}
});
return false;
});
});
</script>
<body>
<form id="form1" name="form1">
<input name="a1" />
<input name="a2" />
<input id="File1" type="file" name="File1"/>
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
ÈçºÎÓÃjqueryʵÏÖÒì²½¿çÓòÌá½»±íµ¥ÄØ?
1.ÀûÓÃscript µÄ¿çÓò·ÃÎÊÌØÐÔ£¬½áºÏform±íµ¥µÄÊý¾Ý¸ñʽ»¯£¬ËùÒÔÖ»ÄܲÉÓÃget·½Ê½Ìá½»,ΪÁË°²È«£¬ä¯ÀÀÆ÷ÊDz»Ö§³Öpost¿çÓòÌá½»µÄ¡£
2.²ÉÓÃJSONP¿çÓòÌá½»±íµ¥ÊDZȽϺõĽâ¾ö·½°¸¡£
3.Ò²¿ÉÒÔ¶¯Ì¬³ÌÐò×öÒ»´úÀí¡£ÓôúÀíÖÐת¿çÓòÇëÇó¡£
ʹÓà jQuery Òì²½¿çÓòÌá½»±íµ¥´úÂ룺
<html xmlns="">
<head>
<title>jqueryÒì²½¿çÓòÌá½»±íµ¥-php×ÔѧÍø</title>
</head>
<script src=""></script>
<script>
jQuery(function($)
{
// ʹÓà jQuery Òì²½¿çÓòÌá½»±íµ¥
$('#f1').submit(function(){
$.getJSON("ta.aspx?"+$('#f1').serialize()+"&jsoncallback=?",
function(data){
alert(data);
});
return false;
});
});
</script>
<body>
<form id="form1" name="form1">
<input name="a1" />
<input name="a2" />
<input id="File1" type="file" name="File1"/>
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
תÔØÇë×¢Ã÷³ö´¦:
¡¡