dongqu5650 2013-08-05 15:10
浏览 68
已采纳

jquery alert(data)显示数据但不能在div内部呈现

I've a textarea with id=wraped and it contains some html codes. I'm trying to send it to fsjquery.php wire ajax get method and save data into sql database.

Before sending the data i'm removing the ids from the html codes which is in the textarea and add a new class to those codes. When alert function is called, it shows the correct data. but, with ajax it renders only the below

<div class="dragmenew ui-draggable" style="left: 48px; top: 139px;"></div>

links inside it is missing.. where are the remaining codes ..?

i'm just simply echoing the received data: echo "this is the quote ".$quote = $_GET['updatequote'];

function fsshowwraped() {
    var datawraped = $('#wraped').html();
    datawraped = datawraped.replace('id="dragme"','');
    datawraped = datawraped.replace('id="dragme2"','');
    datawraped = datawraped.replace('id="dragme3"','');
    datawraped = datawraped.replace('class="dragme','class="dragmenew');
    var obj = $('#obj').html();
    $('#checkwraped').html(datawraped);
    var data = $('#checkwraped').val();
    alert(data);
            alert(datawraped);
    $.ajax({url: 'fsjquery.php',
            data: 'updatequote='+data +'&obj='+obj, 
             type: 'get', 
             datatype: 'html',
              async: false,
              success: function(outData) {$('#bar').html(outData);
    }
    }); 

Data printed on alert(data) is below

<div class="dragmenew ui-draggable"  style="left: 48px; top: 139px;">
<a href="?cat=stories&id=366">dddddddddddd</a></div>
<div class="dragme ui-draggable"  style="left: 420px; top: 6px;">
<a href="?cat=stories&id=364">sdddddddddddddd</a></div>
<div class="dragme ui-draggable"  style="left: 616px; top: 134px;">
<a href="?cat=News&id=358">ddddddddddddddddd</a></div>
  • 写回答

2条回答 默认 最新

  • dos8244 2013-08-06 17:09
    关注

    i found out that the problem is caused by the data which i'm trying to send to php file wire .ajax method. It is caused by the character '&' in the data. I've just replaced '&' to a '$'

    datawraped = datawraped.replace(/&amp;/g,'$');
    

    and then replace that '$' in php file.

    $quote = str_replace('$','&',$quote);
    

    It seems my problem is solved.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)