jquery ajax, $.get(), $.post() »ç¿ë¹æ¹ý |
|
|
 |
13³â Àü |
[ajax]
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
[get, post]
$.get("test.php");
$.get("test.php", { name: "John", time: "2pm" } );
$.get("test.cgi", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});
$.get('ajax/test.html', function(data) {
$('.result').html(data);
alert('Load was performed.');
});
var jqxhr = $.get("example.php", function() {
alert("success");
})
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });
Example: Gets the test.php page contents which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>).
$.get("test.php", { "func": "getNameAndTime" },
function(data){
alert(data.name); // John
console.log(data.time); // 2pm
}, "json"); |
|
̵̧ : 687 |
̵̧
¸ñ·Ï
|
|