$(function () { $("#Btn_Get").click(function () { $.get("/echo/html/", {html: "Get Data"}, function (data) { $("#result").append(html); }); }); $("#Btn_Post").click(function () { $.post("/echo/html/", {html: "Post Data"}, function (data) { $("#result").html(data); }); }); $("#Btn_Load").click(function () { $("#result").load("/echo/html/", {html: "Load Data"}); }); $("#Btn_GetJSON").click(function () { $.getJSON("/echo/json/", {json:{firstName: "aa", lastName: "bb"}}, function (data) { var html = "firstName = " + data.firstName + "<br/>"; html += "lastName = " + data.lastName; $("#result").html(html); }); }); $("#Btn_GetScript").click(function(){ var js = "$('#result').html('get script data');"; $.getScript("/echo/js/?delay=2&js=" + js); }); });
<input type="button" id="Btn_Get" value="get" /> <input type="button" id="Btn_Post" value="post" /> <input type="button" id="Btn_Load" value="load" /> <input type="button" id="Btn_GetJSON" value="getJSON" /> <input type="button" id="Btn_GetScript" value="getScript" /> <br /> <fieldset> <legend>Result</legend> <div id="result"></div> <br /> </fieldset>