{"id":147,"date":"2012-11-21T23:27:47","date_gmt":"2012-11-21T20:27:47","guid":{"rendered":"http:\/\/meekconsulting.com\/?p=147"},"modified":"2012-11-21T23:34:17","modified_gmt":"2012-11-21T20:34:17","slug":"using-fading-div-tag-messages-to-show-ajax-call-results-without-requiring-click","status":"publish","type":"post","link":"https:\/\/meekconsulting.com\/?p=147","title":{"rendered":"Using Fading Div tag messages to show ajax call results without requiring click."},"content":{"rendered":"<p>We use xajax calls to server functions to update databases or insert records from a web page. Usually when they finish they return javascript to close the dialog or div tag and show an alert &#8212; this can be maddening if you are trying to add a lot of data and have to click to acknowledge the alert each time.<\/p>\n<p>So this solution works well to give visual confirmation that doesn&#8217;t require clicking.<\/p>\n<blockquote><p>\/\/ Normal close dialog and remove edit form div<\/p>\n<p>$objResponse-&gt;script(&#8221; $(&#8216;#edit_item&#8217;).dialog(&#8216;close&#8217;);&#8221;);<br \/>\n$objResponse-&gt;remove(&#8216;edit_item&#8217;);<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ Replace table with new updated values and call jquery data table to make look good<\/p>\n<p>$objResponse-&gt;assign(&#8220;table_content_div&#8221;,&#8221;innerHTML&#8221;, &#8220;$html&#8221;);<br \/>\n$objResponse-&gt;script(&#8220;$(&#8216;#item_table&#8217;).dataTable( {<br \/>\nbJQueryUI: true,<br \/>\nbAutoWidth: false,<br \/>\naoColumns: [{&#8216;sWidth&#8217;:&#8217;10%&#8217;},{&#8216;sWidth&#8217;:&#8217;30%&#8217;},{&#8216;sWidth&#8217;:&#8217;60%&#8217;}],<br \/>\nsScrollY: &#8216;400px&#8217;,<br \/>\nbSort: false,<br \/>\nbScrollCollapse: true,<br \/>\nbProcessing: true,<br \/>\nbDeferRender: true,<br \/>\niDisplayLength: &#8216;-1&#8217;,<br \/>\naLengthMenu: [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, &#8216;All&#8217;]]<br \/>\n}); &#8220;);<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ create div tag with message<\/p>\n<p>$objResponse-&gt;create(&#8216;table_content_div&#8217;,&#8217;div&#8217;,&#8217;done_message&#8217;);<br \/>\n$html = &#8220;&lt;img src=\\&#8221;images\/Check_Icon.png\\&#8221; alt=\\&#8221;Save Complete\\&#8221;\/&gt; Save Complete&#8221;;<br \/>\n$objResponse-&gt;assign(&#8216;done_message&#8217;,&#8217;innerHTML&#8217;,&#8221;$html&#8221;);<\/p>\n<p>\/\/ jquery dialog<br \/>\n$objResponse-&gt;script(&#8221; $(&#8216;#done_message&#8217;).dialog({<br \/>\nwidth: 300,<br \/>\nheight: 100,<br \/>\nmodal:true,<br \/>\nresizable: false,<br \/>\ndraggable: false,<br \/>\ndialogClass: &#8216;done_message&#8217;<br \/>\n});&#8221;);<br \/>\n$objResponse-&gt;script(&#8221; $(&#8216;#done_message&#8217;).closest(&#8216;.ui-dialog&#8217;).find(&#8216;.ui-dialog-titlebar&#8217;).hide();&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ Fade away WITHOUT requiring a click &#8212; adjust numbers to effect speed<br \/>\n$objResponse-&gt;script( &#8220;setTimeout(function(){ $(&#8216;#done_message&#8217;).fadeOut(300, function(){ $(this).remove();});}, 500);\u00a0 &#8220;);<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>That&#8217;s It.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We use xajax calls to server functions to update databases or insert records from a web page. Usually when they finish they return javascript to close the dialog or div tag and show an alert &#8212; this can be maddening &hellip; <a href=\"https:\/\/meekconsulting.com\/?p=147\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,8],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-php","tag-xajax"],"_links":{"self":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=147"}],"version-history":[{"count":6,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":154,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions\/154"}],"wp:attachment":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}