-- JQuery

JQuery load, getJSON

어린왕자악꿍 2012. 8. 3. 14:05

general load file


<scripttype="text/javascript">

$(document).ready(function() {

$("#copyright").load("copyright.html");

});

</script>

 

<divid="copyright">copyright</div>



getJSON


<scripttype="text/javascript">

$(document).ready(function() {

$.getJSON("data.json", function(json) {

alert(json.name + " " + json.age);

});

});

</script>

 

[data.json]

 

{

"name" : "NEO",

"age" : "11"

}



passing data to the server


<scripttype="text/javascript">

$(document).ready(function() {

$("div").load("test.jsp",{"name":"NEO"});

});

</script>

 

<divid="ajax_content"></div>