RE: [PHP] connecting php long-polling to the database
| From: | hadi | Date: | Wed, 04 Feb 2015 21:20:14 +0000 |
| Subject: | RE: [PHP] connecting php long-polling to the database | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324385@lists.php.net to get a copy of this message | ||
> 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.
>
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();
});