Re: connecting php long-polling to the database
| From: | Jeffry Killen | Date: | Thu, 05 Feb 2015 02:30:39 +0000 |
| Subject: | Re: connecting php long-polling to the database | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324391@lists.php.net to get a copy of this message | ||
On Feb 4, 2015, at 5:30 PM, Jim Lucas wrote:
On 02/04/2015 01:20 PM, hadi wrote:The error that is printied here is "invalid character". (SCRIPT1014: Invalid character) I have found that sometimes there are foreign, non printing characters in what should be plain text files. I found that in php code that I copied from an e-mail reply to a query. I kept getting a mysterious parse error. The way I found out was to load the script literally into <pre><code>(script)</code></pre> Then way the browser renders a character it does not understand is to show a dark diamond shape with a white question mark in the center. You can find the line it occures in in the script source and back space over it. Also, in a text editor designed for source code (I use BBEdit). there may be a menu item like "zap gremlins" (as it is in BBEdit) which may remove all the foreign characters. (probably hangovers from a word processing program like MS Office or Open Office, or even RTF files.) JKI know in firefox, you view source, you can click and load the files linked to via your <link> and <script> tags. If you can, see what you get when you click on the one for jquery. The browser does appear to load the file. Just that their is an error within the file. Inspect the loaded file at that location to see if you see anything obviously wrong.hadi wrote:When I open my php script direct I can see my table. Working fine. But throw AJAX not working. I think the problem from server.php script, can you please check my codein your end. I suggest to check the error console of your browser.
In my bowers console I get this error HTML1300: Navigation occurred. File: index.html HTML1527: DOCTYPE expected. Consider adding a valid HTML5 doctype: "<!DOCTYPE html>". File: index.html, Line: 1, Column: 1 SCRIPT1014: Invalid character File: jquery.min.js, Line: 4, Column: 15725 Also im getting error from client.js from my browser debugger ** * AJAX long-polling * * 1. sends a request to the server (without a timestamp parameter) * 2. waits for an answer from server.php (which can take forever) * 3. if server.php responds (whenever), put data_from_file into #response * 4. and call the function again * * @param timestamp */ function getContent(timestamp) { var queryString = {'timestamp' : timestamp}; $.ajax(--Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php{ type: 'GET', url: 'http://192.168.206.129/record/server.php', data: queryString, success: function(data){Invalid character// put result data into "obj" var obj = jQuery.parseJSON(data); X Error // put the data_from_file into #response $('#response').html(obj.data_from_file); // call the function again, this time with the timestamp we just got from server.php getContent(obj.timestamp); } }); } // initialize jQuery $(function() { getContent(); });