Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. Yes, it turns out that the value of the podType variable was still available within the success function. Placing quotations marks around the switch options was also very important. Have a great weekend! Tell nest tea Roddy
  2. BACKGROUND: I have successfully integrated both pagination and the simplePagination paginator into my website. Now I must fine tune the integration so as to overcome several associated non-optimal conditions. In order to achieve it appears that I need to understand better the use of the variables and functions utilized with the AJAX request. Please consider the following pieces of code and answer the questions below. The JAVASCRIPT: .click(function() { $.ajax({ url: '_utilities/php/ajax_data_dscr.php', dataType: 'JSON', data: { 'podType': podType }, statusCode: { 404: function() { alert( "Page not found" ); }}, success: function (jsonData){ console.log(jsonData) $('#main').html(''); $.each(jsonData, function(key, object){ $('#main').append("<div class='paginate'><div class='item_info podcast_item'><div class='pod_num'>" + object.podcast_no_item + "</div><div class='pod_title'>" + object.item_title + "<br />" + object.item_pubdate + "</div></div><div class='pod_describe'>" + object.item_description + "</div></div>"); }); var collection = $(".paginate"); var collNum = collection.length; var perPage = 10; collection.slice(perPage).hide(); $("#pagn").pagination({ items: collNum, itemsOnPage: perPage, cssStyle: "light-theme", onPageClick: function(pageNum) { var start = perPage * (pageNum - 1); var end = start + perPage; // console.log(event); // console.log(pageNum); collection.hide().slice(start, end).show(); } }); } The HTML: <div id='main'>...</div><!-- end div#main --> <div id='pagn'>&nbsp;</div><!-- end div#pagn --> BACKGROUND: From the above code you can probably notice that the #main DIV is emptied before it is dynamically filled via jQuery's .append() method. The heading of the newly filled #main DIV should vary with the kind of information that is entered. To this end I created the following switch. Unfortunately, however, I cannot get it to work. Either the value of the podType variable is not being read, or the code itself has not been properly set into the AJAX routine. The following is an example of one of my attempts. beforeSend: function(podType) { $('#main').html(''); switch (podType) { case clausal: $('#main').html('<h1>Clausal Analysis</h1>'); break; case linear: $('#main').html('<h1>Linear Analysis</h1>'); break; case inversion: $('#main').html('<h1>Socratic Inversion</h1>'); break; case chrono: $('#main').html('<h1>All Categories</h1>'); break; } } QUESTION ONE: How do I access the key-value pair entered as the value of the data property? QUESTION TWO: How would you go about insuring that a new list heading is entered with each different value of podType. NOTE: You can visit the page by clicking on the words PROXY LINK at the bottom of http://www.grammarcaptive.com/sender_proxy.php In the navigation bar on the page that opens find the word Chronology, click on it, and then click on the phrase Podcast index ... This will show you a successful implementation of simplePagination and provide you with a visual understanding of what I am able and not able to achieve. Roddy
  3. Hi, i am sending along a copy of a JSON object that I created from a PHP array using a PHP method called json_encode(). This is what it looks like. [ {"podcast_no_item":54,"item_title":"Experiment Two","item_description":"Test","item_pubdate":"2017-06-18 10:31:48"}, {"podcast_no_item":54,"item_title":"Experiment Two","item_description":"Test","item_pubdate":"2017-06-18 10:31:48"}, {"podcast_no_item":55,"item_title":"Experiment Three","item_description":"Test","item_pubdate":"2017-06-18 11:10:56"}, {"podcast_no_item":55,"item_title":"Experiment Three","item_description":"Test","item_pubdate":"2017-06-18 11:10:57"}, {"podcast_no_item":55,"item_title":"Experiment Three","item_description":"Test","item_pubdate":"2017-06-19 08:43:49"}, {"podcast_no_item":55,"item_title":"Experiment Three","item_description":"Test","item_pubdate":"2017-06-19 08:43:49"}, {"podcast_no_item":57,"item_title":"Eureka_3","item_description":"I have found it.","item_pubdate":"2017-09-24 11:03:50"}, {"podcast_no_item":58,"item_title":"Is it ready?","item_description":"It sure looks like it.","item_pubdate":"2017-06-19 15:44:59"}, {"podcast_no_item":58,"item_title":"Is it ready?","item_description":"It sure looks like it.","item_pubdate":"2017-06-19 17:21:11"} ] I have included spaces and tabs so that it is easy for you to read. You can think of a JSON object as one very long array element whose sub-elements consist of a series of objects with property-value pairs. For example, the above JSON object contains nine objects with four property-value pairs each. I am not at all sure that the extension on your file is important. I have seen JSON contained in several different file formats. In any case, make sure that you do not place a comma after the last object in the array element. Also, if you would like to assign the object to a variable as a string so that you can pass it with a $_GET or $_POST HTTP request, make sure that you enclose it in quotation marks and understand that your JSON object is now a JSON string and must be converted back to an object after it has been sent and received. Sometimes this is done automatically. Sometimes it is not in which case you can use JSON.parse(). Roddy
  4. The problem has been resolved by echoing a JSON string produced with json_encode( ) and eliminating the JSON.parse function in the success function. Apparently the new version of $.ajax( ) parses incoming data strings automatically. Try it and see: You are welcome to try it at http://www.grammarcaptive.com/podcasting/experimentation/exp2/podcast_index.php
  5. Good morning! Firstly, I receive a parse error when I echo the PHP variable $json_data without the Javascript. In contrast, I receive no error message when I use the Javascript. I believe now that the problem is with the success function. Find below the two key functions that together produce no error, but still do not produced the expected result -- namely, the alert and a value in the console window. <script> (function jsonOutput() { var jsonData = '<?php echo $json_data; ?>'; jsonData = JSON.stringify(jsonData); return jsonData; })() </script> and success: function(jsonData){ var data_array = JSON.parse(jsonData); document.console && console.log(data_array); alert(data_array[0]['podcast_no_item']); } and still again, [ [60,"New Title","Test","2017-06-19 17:26:41"], [51,"The First Tri-Lateral Attempt","Having rearranged the PHP code, the MySQL database will not be updated until all mandatory elements have been completed and the submit button is depressed.","2017-06-18 09:50:37"], [52,"Cooperation","New description","2017-09-24 11:00:17"], [52,"New Title","New description","2017-06-18 09:56:36"], [53,"Experiment One","Test","2017-06-18 10:24:49"], [54,"Experiment Two","Test","2017-06-18 10:31:48"], [54,"Experiment Two","Test","2017-06-18 10:31:48"], [55,"Experiment Three","Test","2017-06-18 11:10:56"], [55,"Experiment Three","Test","2017-06-18 11:10:57"], [55,"Experiment Three","Test","2017-06-19 08:43:49"], [55,"Experiment Three","Test","2017-06-19 08:43:49"], [57,"Eureka_3","I have found it.","2017-09-24 11:03:50"], [58,"Is it ready?","It sure looks like it.","2017-06-19 15:44:59"], [58,"Is it ready?","It sure looks like it.","2017-06-19 17:21:11"], [60,"New Title","Test","2017-06-19 17:24:23"], [60,"New Title","Test","2017-06-19 17:26:41"], [60,"New Title","Test","2017-08-18 08:21:45"], [63,"Test","Test","2017-08-18 08:21:27"], [64,"Podcast #64","Practice Podcast","2017-08-18 08:21:04"], [65,"Transition Without End","There is a time for everything including a time to end.","2017-08-18 08:20:42"], [60,"New Title","Test","2017-06-19 17:26:41"] ] And, still again, if there is doubt or a need for further experimentation. You are welcome to try it at http://www.grammarcaptive.com/podcasting/experimentation/exp2/podcast_index.php
  6. As before you are welcome to view the entire procedure at You are welcome to try it at http://www.grammarcaptive.com/podcasting/experimentation/exp2/podcast_index.php
  7. Although I am happy to report that I have managed to rid myself of the Object: object and am likely now in communication with the data file, I am still unable to achieve the desired result -- namely, the Javascript alert ( ) and more positive feedback from the introduction of the console.log( ) method. I believe that there were several coding mistakes that were bringing about the original error message including a missing parenthesis in the condition of the data file's if-statement and my treatment of the $.getJSON arguments. I have switched to the $.ajax( ) method, as its format provides me with greater flexibility and a clearer picture of what I am actually trying to achieve. Further, I have move the Javascript outside of the PHP routine in the requested data file. In addition, I have checked to insure that the desired JSON object actually exists and have displayed the result below. The check was made by turning off the $_GET request and running a simple echo statement of the result. In addition, please find below the PHP file that generates the JSON string and the AJAX triggered by a click function using the $.ready( ) method. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if(isset($_GET['podType'])) { define('_HOST_NAME','...'); define('_DATABASE_NAME','...'); define('_DATABASE_USER_NAME','...'); define('_DATABASE_PASSWORD','...'); $mysqli_obj = new MySQLi(_HOST_NAME,_DATABASE_USER_NAME,_DATABASE_PASSWORD,_DATABASE_NAME); if($mysqli_obj->connect_errno) { die("ERROR : -> ".$mysqli_obj->connect_error); } $tbl_name = 'rss2_podcast_item'; $podcast_items = []; $result_obj = $mysqli_obj->query("SELECT * FROM " . $tbl_name); while($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $item_arr[$key] = $value; } $items[] = $item_arr; } //Creates a nested array whose subarrays consist of the four indicated elements. foreach ($items as $sub_arr => $element) { $podcast_item[] = $element['podcast_no_item']; $podcast_item[] = $element['item_title']; $podcast_item[] = $element['item_description']; $podcast_item[] = $element['item_pubdate']; $podcast_items[] = $podcast_item; $podcast_item = []; } $json_data = json_encode($podcast_items, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK); } ?> <script> (function jsonOutput() { var jsonData = '<?php echo $json_data; ?>'; jsonData = JSON.stringify(jsonData); return jsonData; })() </script> .click(function() { $.ajax({ url: '../exp1/ajax_data.php', dataType: 'JSON', data: {'podType': podType}, success: function(jsonData){ var data_array = $.parseJSON(jsonData); document.console && console.log(data_array); alert(data_array[0]['podcast_no_item']); } }); }) [ [60,"New Title","Test","2017-06-19 17:26:41"], [51,"The First Tri-Lateral Attempt","Having rearranged the PHP code, the MySQL database will not be updated until all mandatory elements have been completed and the submit button is depressed.","2017-06-18 09:50:37"], [52,"Cooperation","New description","2017-09-24 11:00:17"], [52,"New Title","New description","2017-06-18 09:56:36"], [53,"Experiment One","Test","2017-06-18 10:24:49"], [54,"Experiment Two","Test","2017-06-18 10:31:48"], [54,"Experiment Two","Test","2017-06-18 10:31:48"], [55,"Experiment Three","Test","2017-06-18 11:10:56"], [55,"Experiment Three","Test","2017-06-18 11:10:57"], [55,"Experiment Three","Test","2017-06-19 08:43:49"], [55,"Experiment Three","Test","2017-06-19 08:43:49"], [57,"Eureka_3","I have found it.","2017-09-24 11:03:50"], [58,"Is it ready?","It sure looks like it.","2017-06-19 15:44:59"], [58,"Is it ready?","It sure looks like it.","2017-06-19 17:21:11"], [60,"New Title","Test","2017-06-19 17:24:23"], [60,"New Title","Test","2017-06-19 17:26:41"], [60,"New Title","Test","2017-08-18 08:21:45"], [63,"Test","Test","2017-08-18 08:21:27"], [64,"Podcast #64","Practice Podcast","2017-08-18 08:21:04"], [65,"Transition Without End","There is a time for everything including a time to end.","2017-08-18 08:20:42"], [60,"New Title","Test","2017-06-19 17:26:41"] ] I look forward to a speedy remedy of my ignorance. Finally, I have replaced the deprecated jQuery .parseJSON() function with the Javascript JSON.parse() function. Roddy
  8. I even found a missing parenthesis in the condition expression of the if-statement and fixed that. Still, the error message remains the same.
  9. Yes, I have cleared the cache. You are welcome to try it at http://www.grammarcaptive.com/podcasting/experimentation/exp2/podcast_index.php Find the <div> entitled Navigation Bar and click on any of the menu items. Each will send a different value for podType, but the if condition that controls the PHP in the data file does not care what it receive, just so long as it is something. Roddy
  10. I also tried this <?php ... ?> <script> (function jsonOutput() { var jsonData = '<?php echo $json_data; ?>'; jsonData = JSON.stringify(jsonData); return jsonData; })() </script> but still, the error message and associated link remain unchanged.
  11. 1) No. I am not building the URL, I am simply entering it as a relative path. 2) Also, because $.getJSON() appears to be a special case of $.ajax(), I should think that it follows the same rules for the data parameter. This is what it says for the parameter for $.ajax(). So, I believe you are correct about the reformatting of the value that I enter for the data parameter. 3) You wrote: Yes, but how to I output the JSON string. Originally, I did it as a PHP echo statement. I understand far too poorly what $.ajax() does when the dataType is 'JSON'. I changed the data parameter to read $.getJSON({ url: '../exp1/ajax_data.php', data: {'podType': podType}, success: function(jsonData){ var data_array = $.parseJSON(jsonData); alert(data_array[0]['podcast_no_item']); } }); and the data file to read <?php if(isset($_GET['podType']) { define('_HOST_NAME','baha.lunarbreeze.com'); define('_DATABASE_NAME','thege0_grammarcaptive'); define('_DATABASE_USER_NAME','thege0'); define('_DATABASE_PASSWORD','Liberty2015'); $mysqli_obj = new MySQLi(_HOST_NAME,_DATABASE_USER_NAME,_DATABASE_PASSWORD,_DATABASE_NAME); if($mysqli_obj->connect_errno) { die("ERROR : -> ".$mysqli_obj->connect_error); } $tbl_name = 'rss2_podcast_item'; $podcast_items = []; $result_obj = $mysqli_obj->query("SELECT * FROM " . $tbl_name); while($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $item_arr[$key] = $value; } $items[] = $item_arr; } //Creates a nested array whose subarrays consist of the four indicated elements. foreach ($items as $sub_arr => $element) { $podcast_item[] = $element['podcast_no_item']; $podcast_item[] = $element['item_title']; $podcast_item[] = $element['item_description']; $podcast_item[] = $element['item_pubdate']; $podcast_items[] = $podcast_item; $podcast_item = []; } $json_data = json_encode($podcast_items, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK); } ?> <script> var jsonData = '<?php echo $json_data; ?>'; jsonData = JSON.stringify(jsonData); </script>
  12. This is all that I am doing. $.getJSON({ url: "../exp1/ajax_data.php", data: podType, success: function(json_data){ var data_array = $.parseJSON(json_data); alert(data_array[0]['podcast_no_item']); } }); I read this in simple English as, "Send an HTTP request with the value of podType to '../exp1/ajax_data.php'. Discover a variable called json_data in ajax_data.php" . Read the value of json_data into the success call function for further processing. Convert the JSON string into a JSON object and extract from it the value of the first element of the first subarray of the Javascript array just created. This too fails. Is this the source of the problem? Must this be stringified before it is sent back to the requesting file? [[60,"New Title","Test","2017-06-19 17:26:41"],[51,"The First Tri-Lateral Attempt","Having rearranged the PHP code, the MySQL database will not be updated until all mandatory elements have been completed and the submit button is depressed.","2017-06-18 09:50:37"],[52,"Cooperation","New description","2017-09-24 11:00:17"],[52,"New Title","New description","2017-06-18 09:56:36"],[53,"Experiment One","Test","2017-06-18 10:24:49"],[54,"Experiment Two","Test","2017-06-18 10:31:48"],[54,"Experiment Two","Test","2017-06-18 10:31:48"],[55,"Experiment Three","Test","2017-06-18 11:10:56"],[55,"Experiment Three","Test","2017-06-18 11:10:57"],[55,"Experiment Three","Test","2017-06-19 08:43:49"],[55,"Experiment Three","Test","2017-06-19 08:43:49"],[57,"Eureka_3","I have found it.","2017-09-24 11:03:50"],[58,"Is it ready?","It sure looks like it.","2017-06-19 15:44:59"],[58,"Is it ready?","It sure looks like it.","2017-06-19 17:21:11"],[60,"New Title","Test","2017-06-19 17:24:23"],[60,"New Title","Test","2017-06-19 17:26:41"],[60,"New Title","Test","2017-08-18 08:21:45"],[63,"Test","Test","2017-08-18 08:21:27"],[64,"Podcast #64","Practice Podcast","2017-08-18 08:21:04"],[65,"Transition Without End","There is a time for everything including a time to end.","2017-08-18 08:20:42"],[60,"New Title","Test","2017-06-19 17:26:41"]]
  13. Are you suggesting that the PHP echo statement produces an object? I just replaced the following with the code that follows. FOLLOWING CODE echo json_encode($podcast_items, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK); CODE THAT FOLLOWS <?php ... $json_data = json_encode($podcast_items, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK); ?> <script> var json_data = '<?php echo $json_data; ?>'; </script> <?php Still no change: the alert does not appear and the error message along with the accompanying URL remain the same. Roddy
  14. OK. Here are the two paths: ... /experimentation/exp2/podcast_index.php .../experimentation/exp1/ajax_data.php The value of the URL property of the AJAX object in podcast_index.php is url: "../exp1/ajax_data.php", I have checked the spelling of each folder and file. I find nothing wrong. Any other ideas? This is what the Javascript Console returns as part of the error message. http://www.grammarcaptive.com/podcasting/experimentation/exp2/[object Object] Is $.getJSON looking for a JSON object as the value of a defined variable, when indeed, I am only echoing the JSON string? If this is the problem what form should the variable take? Can I use a PHP variable? Must it be a Javascript variable? How should I set the datatype of the $.ajax() or $.getJSON() PlainObject to correspond? Truly, I do not know how AJAX retrieves its desired information. Does it scan the entire page looking for a variable name? Does it look for some sort of page output? Or, does it simply read everything of the designated data type regardless if it is needed? None of the literature that i have read tells what truly happens once the designated URL has been accessed.
  15. BACKGROUND: I have created a PHP routine that gathers data from a MySQL database. The data that it gathers depends on the value of an HTTP request that uses the $_GET superglobal as its transfer mechanism. The routine further organizes the retrieved information into a nested array such that each element of the array corresponds to a different table row, and each element of each nested array corresponds to a subset of the table fields. Once the nested array has been completed the json_encode() function converts the array into a JSON string and readies it for transport. The PHP <?php if(isset($_GET['podType']) { define('_HOST_NAME','...'); define('_DATABASE_NAME','...'); define('_DATABASE_USER_NAME','...'); define('_DATABASE_PASSWORD','...'); $mysqli_obj = new MySQLi(_HOST_NAME,_DATABASE_USER_NAME,_DATABASE_PASSWORD,_DATABASE_NAME); if($mysqli_obj->connect_errno) { die("ERROR : -> ".$mysqli_obj->connect_error); } $tbl_name = 'rss2_podcast_item'; $podcast_items = []; $result_obj = $mysqli_obj->query("SELECT * FROM " . $tbl_name); while($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $item_arr[$key] = $value; } $items[] = $item_arr; } //Creates a nested array whose subarrays consist of the four indicated elements. foreach ($items as $sub_arr => $element) { $podcast_item[] = $element['podcast_no_item']; $podcast_item[] = $element['item_title']; $podcast_item[] = $element['item_description']; $podcast_item[] = $element['item_pubdate']; $podcast_items[] = $podcast_item; $podcast_item = []; } echo json_encode($podcast_items, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK); } ?> The Javascript <script> $(document).ready(function() { $('li.podDex').each(function(){ var podType = $(this).attr('id'); //Causes the weight of the font to change when the mouse passes over the text. $('#'+podType).mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .mouseout(function() { $(this).css("font-weight", "normal"); }); //Causes the weight of the font to change, displays the hidden text to appear in the #main <div> element, and brings about a change in color. $('#'+podType).mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .click(function() { $.getJSON({ url: "../exp1/ajax_data.php", data: podType, success: function(json_data){ var data_array = $.parseJSON(json_data); alert(data_array[0]['podcast_no_item']); } }); }) .mouseup(function() { $(this).css({"color": "#fadb9d","font-weight": "normal"}); $('body, html').animate({scrollTop: $('#main').offset().top},800); }); }); }); </script> The HTML <ul> <li id='linear' class='podDex'>Linear Analysis</li> <li id='clausal' class='podDex'>Clausal Analysis</li> <li id='inversion' class='podDex'>Socratic Inversion</li> <li id='chronology' class='podDex'>Chronology</li> </ul> The Console Error Message is You are welcome to try it yourself. Please go to Grammar Captive and click on any of the four designated <li> elements. QUESTION: What might be causing the $.getJSON() call to fail? NOTE: A similar, but not identical, result occurs on my local test server.
  16. I understand, but I need the variable for another process. The anonymous function associated with .click() method is just a placeholder.
  17. No. This $('#' + podType). does not work. And, for the same reason, I believe $(this) will not work. There is something deeper that is afoul. Roddy Edit: No, I take it back. When placed inside the $.ready( ) function it works fine. I am not the hopeless case that I originally thought.
  18. Please consider the two following sets of code and explain why the Javascript not work and suggest an alternative where possible. There are zero complaints from the Javascript console. None. And, the var podType is properly identified. I have checked with console.(log) The procedure does not even turnover for the final element. I am baffled. <script> $(document).ready(function() { $('li.podDex').each(function(){ var podType = $(this).attr('id'); $('#podType').mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .mouseout(function() { $(this).css("font-weight", "normal"); }); $('#podType').mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .click(function() { var chrono_var = $("#chronology_div").html(); $("#main").html(chrono_var); }) .mouseup(function() { $(this).css({"color": "#fadb9d","font-weight": "normal"}); $('body, html').animate({scrollTop: $('#main').offset().top},800); }); }); }); </script> <ul> <li id='linear' class='podDex'>Linear Analysis</li> <li id='clausal' class='podDex'>Clausal Analysis</li> <li id='inversion' class='podDex'>Socratic Inversion</li> <li id='chronology' class='podDex'>Chronology</li> </ul> Mind you, in isolation, when podType refers directly to the appropriate id attribute, what is included in the .each() function works fine! Roddy
  19. So, if I have correctly understood, the expression window.console && console.log(response, pagination); reads as follows: If window.console exists and console.log() can be performed, then execute console.log(). Else, do nothing and proceed to the next statement. Is this correct? Roddy
  20. REQUEST: Please consider the following block of code and answer the question that follows: callback: function (response, pagination) { window.console && console.log(response, pagination); var dataHtml = '<ul>'; $.each(response, function (index, item) { dataHtml += '<li>' + item + '</li>'; }); dataHtml += '</ul>'; container.prev().html(dataHtml); } QUESTION ONE: The word console appears to be a property of the window object. The word log appears to be a method of the console property. window.console && console.log(response, pagination); Why not just write: window.console.log(response, pagination)? Would it not have the same effect? I do not understand the purpose of the author's phrasing.
  21. REQUEST: Please consider the following two blocks of code and answer the questions that follow. The second block is a sub-block of the first. THE MAIN BLOCK: $(function () { function createDemo(name) { var container = $('#pagination-' + name); var sources = function () { var result = []; for (var i = 1; i > 196; i++) { result.push(i); } return result; }(); var options = { dataSource: sources, callback: function (response, pagination) { window.console && console.log(response, pagination); var dataHtml = '<ul>'; $.each(response, function (index, item) { dataHtml += '<li>' + item + '</li>'; }); dataHtml += '</ul>'; container.prev().html(dataHtml); } }; //$.pagination(container, options); container.addHook('beforeInit', function () { window.console && console.log('beforeInit...'); }); container.pagination(options); container.addHook('beforePageOnClick', function () { window.console && console.log('beforePageOnClick...'); //return false }); return container; } createDemo('demo1'); }); THE SUB-BLOCK: var sources = function () { var result = []; for (var i = 1; i > 196; i++) { result.push(i); } return result; }(); QUESTION ONE: The group operator ( ) at the end of the sub-block appears to execute the anonymous function assigned to the reference variable called sources and to assign the result of that execution to the variable. Is this correct? I have seen similar use of the operator in the following context: (function(){...})() However, in this context, the function is enclosed in parentheses, not assigned to a variable. This suggests that the empty group ( ) operator is a "word" of its own, and that after specific kinds of expressions, it is akin to the command "execute what comes before". QUESTION TWO: Is the above a correct assessment? If so, what can and cannot appear before the group operator in order for the group operator to behave in the manner just stated. Roddy
  22. After several hours of investigation and experimentation with two models that I found online, I finally decided upon one. Two more hours past as I sought to make deprecated code recent. When I went to implement the class, however, I discovered that the source file no longer existed. So, I returned to the net and to my very pleasant surprise found the following: pagination.js. Now, I do not want to be hasty in my appraisal, but this piece of jQuery appears to do just about everything you could imaging including an automatic implementation of JSONP. Check out the link provided on the GiiHub page. i am very excited. Roddy
  23. QUESTION ONE: What is it called when you traverse an entire table in equal multiples of records? (I ask this question, because I have been fraught with frustration in my google searches.) QUESTION TWO: Do you know a routine that I can copy and modify? (This would greatly simply my search.) BACKGROUND: Surely there must be a standard routine for performing the following procedure: 1) Use PHP to read and display the first ten records of a MySQL table. 2) Read and display the next ten records of the same data table. 3) Either return to the previously read ten records and display these or continue on to the following ten unread records and display them. 5) When you have reached the end of the table display only the remaining records. GOAL: Ultimately I would like to read and display 10 records in a list format. At the bottom of the list I would place two buttons. One that displays the previously 10 records and one that displays the next ten unread records. WHAT I HAVE ACHIEVED SO FAR: <?php $col_name = 'item_pubdate'; $result_obj = $mysqli_obj->query("SELECT * FROM rss2_podcast_item ORDER BY '$col_name' LIMIT 0, 10"); while($row=$result_obj->fetch_array()) { ?> <div class='table_row podcast_item'> <div class='flex_item num_div'><?php echo $row['podcast_no_item'] . '&nbsp'; ?></div> <div class='flex_item date_div'><?php echo $row['item_pubdate']; ?></div> <div class='flex_item title_div'><?php echo $row['item_title']; ?></div> </div><!-- end div.table_row --> <div class='table_row discover_div'> <div class='flex-item'>Discover more ...</div> </div><!-- end div.table_row --> <div class='table_row'> <div class='flex-item details_div'> <?php echo $row['item_description']; ?> </div><!-- end div.table_row --> </div><!-- end div.table_row --> <?php } ?> With a little additional CSS and Javascript I have been able to achieve the following display. Clicking on the phrase "Discover more ..." reveals the hidden detail obtained from $row['item_description]. No. Publication Date|Time Podcast Title 60 2017-06-19 17:26:41 Title Ten Discover more ... 59 2017-06-18 09:50:37 Title Nine Discover more ... . . . 51 2017-09-24 11:00:17 Title One Discover more ... DESIRE: If I can only achieve the above stated goal, I can likely figure out a way to get AJAX to allow users to select podcast items by the week, month, year, and later category. But, this is already much too far into the future. For the moment, I would simply like to achieve my above stated goal. Any ideas? Roddy
  24. Very useful information, Ingolme. Thanks! Except for the fact that it does not appear to be true for BBEdit -- my code editor. BBEdit phrases the open and close PHP tags instead.
×
×
  • Create New...