PHP Classes

File: WICore/WIJ/index.js

Recommend this page to a friend!
  Classes of Jules Warner   WICMS   WICore/WIJ/index.js   Download  
File: WICore/WIJ/index.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: WICMS
Database driven content management system with PDO
Author: By
Last change:
Date: 7 years ago
Size: 1,848 bytes
 

Contents

Class file image Download
$(document).ready(function () { //comment button click $("#comment").click(function () { //remove all error messages wiengine.removeErrorMessages(); var comment = $("#comment-text"), btn = $(this); //validate comment if($.trim(comment.val()) == "") { wiengine.displayErrorMessage(comment, $_lang.field_required); return; } //set button to posting state wiengine.loadingButton(btn, $_lang.posting); $.ajax({ url: "WICore/WIClass/WIAjax.php", type: "POST", data: { action : "postComment", comment: comment.val() }, success: function (result) { //return button to normal state wiengine.removeLoadingButton(btn); try { //try to parse result to JSON var res = JSON.parse(result); //generate comment html and display it var html = "<blockquote>"; html += "<p>"+res.comment+"</p>"; html += "<small>"+res.user+" <em> "+ $_lang.at +res.postTime+"</em></small>"; html += "</blockquote>"; if( $(".comments-comments blockquote").length >= 7 ) $(".comments-comments blockquote").last().remove(); $(".comments-comments").prepend($(html)); comment.val(""); } catch(e){ //parsing error, display error message wiengine.displayErrorMessage(comment, $_lang.error_writing_to_db); } } }); }); });