成功的Ajax功能后,更换的DIV内容 [英] Replace content in div after successful ajax function

查看:83
本文介绍了成功的Ajax功能后,更换的DIV内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想换成了℃的内容; DIV ID =容器>< / DIV>

  $。阿贾克斯({
      键入:POST,
      网址:脚本/ process.php
      数据:dataString,
      成功:函数(){
        //请告诉我code这里的#conatiner格替换的内容:
        //&其中p为H.;您的文章已成功添加<!/ P>
      }
     });
    返回false;
 

解决方案

http://api.jquery.com/html/

  $。阿贾克斯({
  键入:POST,
  网址:脚本/ process.php
  数据:dataString,
  成功:函数(returnedData){
    $('的#container)。html的(returnedData);
  }
 });
 

也使用 http://api.jquery.com/load/

  $('的#container).load('脚本/ process.php',{你:dataHereAsAnObjectWillMakeItUsePost'});
 

I would like to replace a content of <div id="container"></div> after the ajax function is successful, also without page refresh.

$.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 );
  }
 });

also using http://api.jquery.com/load/,

$( '#container' ).load( 'scripts/process.php', { your: 'dataHereAsAnObjectWillMakeItUsePost' } );

这篇关于成功的Ajax功能后,更换的DIV内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆