weixin_33716557 2016-02-29 10:22 采纳率: 0%
浏览 40

Ajax数据到nicedit textarea

I am using nicedit plugin in php file and it is working fine.

<script type="text/javascript" src="http://js.nicedit.com/nicEdit.js"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
    new nicEditor({buttonList : ['fontSize','bold','italic','underline','ol','ul','strikeThrough','subscript','superscript','forecolor','bgcolor']}).panelInstance('area4');
    nicEditors.findEditor('area4').saveContent();

    });
</script>

I want to put some value in nicedit editor from database by ajax. Here is the ajax code.

    <script type="text/javascript">
    $(function() {
        $("#autofill").change(function() {
            var data1= $('option:selected', this).text();
                            $.ajax({
                        type: "GET",
                        url:"autofill.php",
                        cache: false,
                        data: 'action1=' + data1,
                        beforeSend: function() { 
                            $("#validation-errors").hide().empty(); 
                        },
                        success: function(data) {
                            if(data.success == true)
                                {
                                   data = JSON.parse( data );
                                   $('#area4').val(data.title);
$('html, body').animate({scrollTop: $("#features-left-image").offset().top}, 2000);
                                }
                        },
                        error: function(xhr, textStatus, thrownError) {
                            alert('Something went to wrong.Please Try again later...');
                            btn.button('reset');
                            alert(thrownError);
                        }
                    });             
                    return false;
                });

        });
    </script>

I checked and found json data is returning from autofill.php but for some reason i am not able to show them in nicedit editor. If i use textbox instead of nicedit then data is showing there but it is not working for nicedit textarea.

Have you ever face similar issue?

Thanks for your time.

  • 写回答

1条回答 默认 最新

  • local-host 2016-03-01 04:22
    关注

    Finally i got it working. Here is the code.

    var ed=data.title;
    nicEditors.findEditor('area4').setContent(ed);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程