2
我要插入一些HTML到一個div想這:的Javascript如何逃脫字符
<div id="Sag">
</div>
我使用$('#Sag').html(data)
,爲了將數據插入到這個div ... 但這裏是我的問題數據是:
<table style="direction: rtl;float:right;">
<?php $sess = isset(Yii::app()->session['cart']) ? Yii::app()->session['cart'] : '{}';
$ses = json_decode($sess, true);
foreach ($ses as $i=>$value11){
?>
<tr style="direction: rtl;" class="cart_show">
<td>
<img class="picCart-<?php echo $i; ?>" src="<?php echo Yii::app()->request->baseUrl."/images/".$ses[$i]['properties']['pic_directory'];?>" width="100" heigh="100">
</td>
<td class="descCart-<?php echo $i; ?>">
<?php echo $ses[$i]['properties']['description'];?>
</td>
<td class="priceCart-<?php echo $i; ?>">
<?php echo $ses[$i]['properties']['price'];?>
</td>
<td class="quantityCart-<?php echo $i; ?>">
<input type="text" style="width: 20px;" class="voroodi" value="<?php
echo $ses[$i]['quantity'];
?>">
<button name="delete_from_cart-<?php echo $i; ?>" class="btnDel">??? </button>
<button name="modify_cart-<?php echo $i; ?>" class="btnModify">?????</button>
</td>
</tr>
<?php } ?>
</table>
所以我怎麼能逃脫"
,'
,...?我應該在每一個之前使用一個\
,還是有像在C#中使用JavaScript的@
?
你的數據是什麼?你如何得到這段代碼? – epascarello 2012-02-19 14:39:56
你打算在div中發生什麼?請注意,php不會執行,因爲JavaScript是客戶端。 – 2012-02-19 14:40:45
數據是使用會話來顯示用戶的購物車的東西,所以有什麼其他的想法來達到這個目的。 P.S:指定div的內容將作爲彈出窗口顯示給用戶,所以我認爲這是我的解決方案,向用戶顯示此內容而不重新加載頁面 – Ehsan 2012-02-19 14:49:21