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>
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(/&/g,'$');
and then replace that '$' in php file.
$quote = str_replace('$','&',$quote);
It seems my problem is solved.
Use this one in success function
$('#bar').html(outData.replace(/&/g, "&"));
Hoping it will solve your problem