javascript - How to rewrite table using ajax response -


i'm trying re-write table using javascript , ajax. here request has been sent , response arrived innerhtml cannot re-write table content response text. here code.

<table> <tbody id='product1'> <tr> <td> product name:</td> <td>p1</td> </tr> </tbody> </table>

javascript

function compareprod(prodid,tid){ browse(); var url = 'process.jsp'; url += '?compareprod='+prodid; xmlhttp.onreadystatechange = changeprod(tid); xmlhttp.open('post', url, true); xmlhttp.send(null); } function changeprod(tid) { if (xmlhttp.readystate == 4 || xmlhttp.readystate == 'complete') { document.getelementbyid('product1').innerhtml = xmlhttp.responsetext; } }

process.jsp <tr> <td> product name:</td> <td>p2</td> </tr>

here response arrived cannot rewrite table.

try in single function , check this, on assumption initialized xmlhttp request object.

xmlhttp.onreadystatechange = function(){     if (xmlhttp.readystate==4 && xmlhttp.status==200)     {         document.getelementbyid('product1').innerhtml = xmlhttp.responsetext;     } }; 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -