我想<div id="container"></div>在ajax函数成功后替换内容,也无需刷新页面。
<div id="container"></div>
$.ajax({ type: "POST", url: "scripts/process.php", data: dataString, success: function() { //Whats the code here to replace content in #conatiner div to: //<p> Your article was successfully added!</p> } }); return false;
http://api.jquery.com/html/
$.ajax({ type: "POST", url: "scripts/process.php", data: dataString, success: function( returnedData ) { $( '#container' ).html( returnedData ); } });
也使用http://api.jquery.com/load/,
$( '#container' ).load( 'scripts/process.php', { your: 'dataHereAsAnObjectWillMakeItUsePost' } );