Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery ajax response strips html <td> tags
    text
    copied!<p>I have a javascript / jquery function which is supposed to replace a row in a table with an "Edit Mode" version of the same row. it fires on the onclick event of a button on the row and a simplified verion of the code would be:</p> <pre><code>function EditRow(itemID) { editable_row = getUrl('row.php?action=' + 'edit' + '&amp;itemID=' + itemID ); $('[row_itemID=' + itemID + ']').html(editable_row); } </code></pre> <p>(...row_itemID is an attribute of the TR tag for the row... as in [tr row_itemID="27"])</p> <pre><code>function getUrl(addr) { var r = $.ajax({ type: 'GET', url: addr, async: false, dataType: "text" }).responseText; return r; } </code></pre> <p>(i have alse tried setting "dataType:" to 'html' or leaving it out altogether)</p> <p>row.php should return the "Edit Mode" version of the contents of the row but for some reason the TD tags appear to get stripped in the process, maybe the $.ajax() function consideres a response containing TD 's without TR 's invalid.</p> <p>A view-source of <code>row.php?action=edit&amp;itemID=27</code> displays the TD 's and so does <code>alert(editable_row);</code>, but <code>alert($('[row_itemID=27]').html());</code> doesn't.</p> <p>A simplified version of row.php code:</p> <pre><code>&lt;?php if ($_GET['action'] == 'edit') { $item = ItemDataAccess::Read($_GET['itemID']); ?&gt; &lt;td&gt;&lt;input type="text" name="itemID" value="&lt;?php echo $item-&gt;itemID ?&gt;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="name" value="&lt;?php echo $item-&gt;name ?&gt;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="description" value="&lt;?php echo $item-&gt;description ?&gt;" /&gt;&lt;/td&gt; &lt;?php } ?&gt; </code></pre> <p>Does anyone now how to get it to insert an unadulterated html response into the TR tag?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload