Re: connecting php long-polling to the database
| From: | Jim Lucas | Date: | Thu, 05 Feb 2015 01:30:07 +0000 |
| Subject: | Re: connecting php long-polling to the database | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324390@lists.php.net to get a copy of this message | ||
On 02/04/2015 01:20 PM, hadi wrote:
>
>
>> 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 code
>> in your end.
>>
>> I suggest to check the error console of your browser.
>>
>
I 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.
> 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(
> {
> 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();
> });
>
>
>
>
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/