Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Simple. Re-enable the button and go to the anchor <em>after</em> you receive the request and process the information. Like so:</p> <pre><code>function getComments(type, id) { // ADDED $('#commentList').empty(); $.getJSON("/ajax/"+type+"/comments?jsoncallback=&amp;id="+id, function(data) { for (var x = 0; x &lt; data.length; x++) { var div = $("&lt;div&gt;").addClass("comment").appendTo("#commentList"); var fieldset = $("&lt;fieldset&gt;"); var legend = $("&lt;legend&gt;").addClass("commentHeader"); if ( data[x].url == "" ) { legend.text((x+1) + ' - ' + data[x].name); } else { $("&lt;a&gt;").attr({href: data[x].url}).text((x+1) + ' - ' + data[x].name).appendTo(legend); } legend.appendTo(fieldset); $("&lt;div&gt;").addClass("date").text(data[x].timestamp).appendTo(fieldset); $("&lt;p&gt;").addClass("comment").text(data[x].content).appendTo(fieldset); fieldset.appendTo(div); } // ADDED window.location = "#addComment"; $('#comAdd').removeAttr('disabled'); }); } </code></pre> <p>Personal opinion: rather than fetching <em>all</em> comments, why not fetch comments from a certain date? When you load the page, include a server time in the response. The Javascript uses this to query behind the scenes (to automatically check for new comments). The JSON response includes a new server time, which is used in the next response.</p> <p>How would you handle deleted comments? Easy: have a deleted_on column in your database table, query it, and spit that out in the JSON response along with new posts.</p> <p>Suggestion: instead of <code>#addcomment</code>, ID comments by timestamp.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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