Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing ajax with a while statement and DB
    text
    copied!<p>I have a question about using ajax.I want to delete something of my screen (to be clear, some articles) I'm generating content (the articles) on the screen with this code:</p> <pre><code>while($test = $allArticles-&gt;fetch_assoc()) { echo "&lt;div class='metfoto'&gt;"; echo "&lt;h1 name='tt' class='titelopmaak'&gt;".$test['titel'] . "&lt;br /&gt;&lt;/h1&gt;"; echo "&lt;p class='artikelopmaak'&gt;" . $test['article'] . "&lt;/p&gt;"; echo "&lt;form method='post' action=''&gt;"; echo "&lt;input type='submit' class='delete' name='verwijder' value='verwijder'&gt;"; echo "&lt;/form&gt;"; //echo "&lt;h1&gt;".$test['id']."&lt;/h1&gt;"; echo "&lt;/div&gt;"; } </code></pre> <p>This all is working very well without ajax. But I want to make this(the delete with the button) happen without a page refresh. When i for example check the content of $test['id'], i receive one number. <strong>My problem with the code below is that when i want to put the title into variabel (var titel) for ajax, it loads all the titels from my page.</strong> </p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function(){ $(".delete").click(function(){ var titel = $(".titelopmaak").text(); var artikel = $(".artikelopmaak").text(); $.ajax({ type: "POST", url: "assets/ajax/deleteArticle.php", data: { titelA:titel }, }).done(function( msg ) { if(msg.status != "error") { if(msg.status == "success") { $(".titelopmaak").fadeOut(); } else { } } }); return false; }) }); &lt;/script&gt; </code></pre> <p><strong>EDIT</strong></p> <p><strong>I hope i explained my question in a better way now</strong></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