Some help neededhttp://forums.asp.net/t/1808449.aspx/1?Some+help+neededTue, 29 May 2012 09:55:21 -040018084495001774http://forums.asp.net/p/1808449/5001774.aspx/1?Some+help+neededSome help needed <p>One of my team mate is encountering a problem. Actually he have a database with columns id and name. He have inserted the value manually and then retrieving the values using AJAX function. Below I am attaching the function using which he is retrieving data from the database.</p> <pre class="prettyprint">&lt;script type=&quot;text/javascript&quot;&gt; window.onload = showALL; function showALL() { var xmlrqst; if(window.XMLHttpRequest){ xmlrqst = new XMLHttpRequest(); } else{ xmlrqst = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); } xmlrqst.onreadystatechange = function(){ if(xmlrqst.readyState==4 &amp;&amp; xmlrqst.status==200) { document.getElementById(&quot;userall&quot;).innerHTML = xmlrqst.responseText; } } xmlrqst.open(&quot;GET&quot;,&quot;post.php?get=1&quot;,true); xmlrqst.send(); }// showAll() &lt;/script&gt; the aforementioned javascript is in the index.php. here you can see that i am using a post.php and is passing parameter through the url to post.php below is the code that is being executed in the post.php &lt;?php if(isset($_GET['get'])) { if($_GET['get']!=1) { echo &quot;error&quot;; } $showAll = &quot;SELECT * FROM names&quot;; $showAllQuery = mysql_query($showAll,$con); if(!$showAllQuery){ die(&quot;error&quot;.mysql_error());} echo &quot;&lt;table&gt;&quot;; echo &quot;&lt;th&gt;ID&lt;/th&gt;&quot;; echo &quot;&lt;th&gt;NAME&lt;/th&gt;&quot;; while($output=mysql_fetch_array($showAllQuery)) { $out = $output['id']; echo&quot;&lt;tr&gt;&quot;; echo &quot;&lt;td&gt;{$output['id']}&lt;/td&gt;&quot;; echo &quot;&lt;td&gt;{$output['name']}&lt;/td&gt;&quot;; echo &quot;&lt;td&gt;&lt;a href=\&quot;#\&quot;&gt;delete&lt;/a&gt;&lt;/td&gt;&quot;; echo &quot;&lt;/tr&gt;&quot;; } echo &quot;&lt;/table&gt;&quot;; } ?&gt;</pre> <p>in the post.php he is generating the table with user data and it is being displayed in the index.php file in the &lt;div &gt;&lt;/div&gt; section.<br> <br> Now, lets discuss his problem. The problem is the data are generated in the post.php and is displayed in the index.php in a certain div. How can he delete value from database using AJAX?</p> 2012-05-29T09:47:57-04:005001791http://forums.asp.net/p/1808449/5001791.aspx/1?Re+Some+help+neededRe: Some help needed <pre class="prettyprint">echo &quot;&lt;td&gt;&lt;a href=\&quot;#\&quot;&gt;delete&lt;/a&gt;&lt;/td&gt;&quot;;</pre> <pre class="prettyprint"><span class="pun"><br /></span></pre> <pre class="prettyprint"><span class="pun">instead use </span></pre> <pre class="prettyprint"><span class="pln">echo </span><span class="str">"&lt;td&gt;&lt;a href=\"#\" onclick="return delete(</span>{&#36;output['id']})<span class="str">"&gt;delete&lt;/a&gt;&lt;/td&gt;"</span><span class="pun">;</span></pre> <pre class="prettyprint"><span class="pun"><br /></span></pre> <pre class="prettyprint"><span class="pun">then in javascript</span></pre> <pre class="prettyprint">function delete(id)</pre> <pre class="prettyprint">{</pre> <pre class="prettyprint">callAjax("delete.php?id="+id,result);</pre> <pre class="prettyprint">}</pre> <pre class="prettyprint">function result(data)</pre> <pre class="prettyprint">{</pre> <pre class="prettyprint">display message</pre> <pre class="prettyprint">}</pre> 2012-05-29T09:55:21-04:00