RE: connecting php long-polling to the database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Jim Lucas [mailto:lists@xxxxxxxxx]
> Sent: Thursday, February 05, 2015 4:30 AM
> To: hadi; 'Christoph Becker'; ash@xxxxxxxxxxxxxxxxxxxx
> Cc: php-general@xxxxxxxxxxxxx
> Subject: Re:  connecting php long-polling to the database
> 
> 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.

I opened firefox and inspect the error .
Here is the error from firefox

Error: http://code.jquery.com/jquery.min.js is being assigned a //# sourceMappingURL, but already has one
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. index.html
GET http://192.168.206.129/record/server.php [HTTP/1.1 200 OK 7ms]
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

<br /> <b>Parse error</b>: syntax error, unexpected T_WHILE in <b>/var/www/html/record/server.php</b> on line <b>53</b><br />

Here the error in pointing to line 53 at my server.php script which is sql query

53  $data = while($row = mysqli_fetch_array($result1))
 54
 55
 56  {
 57
 58 echo "<tr>";
 59 echo "<td>" . $row['name'] . "</td>";
 60 echo "<td>" . $row['lastname'] . "</td>";
 61 echo "</tr>";
 62
 63
 64
 65
 66
 67
 68 } 

> 
> 
> > 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/
> 
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux