I just started his android development, some descriptions may not be professional, laughed. Now the situation is such that, android in to load web pages, both to use javascript, jsp code segment is now in the script. Effect of this code is to establish and MySql database using JDBC connection, access to the data needed, and then manage to connect such a simple database operations. I now need to implement the function of this code is to allow every few seconds or a few milliseconds can be able to perform an automatic, because the database is also constantly updated data, so I need to establish a connection to the database every few seconds and get the data. Will To achieve this function, the thread is it? Or use AJAX, JQuery?
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
Hello, I am part of the code is to achieve to re-run every few seconds. You gave me this connection is to refresh the entire page. Reply:
Oh, so ah .... AJAX can be polled, specific to the web version ask under open Reply: 1 js in how there will be a JSP code? JSP code only in the service side ah 2 WEB page using js control refresh timer with setInterval () method Reply:
1 js in how there will be a JSP code? JSP code only in the service side ah 2 WEB page using js control refresh timer with setInterval () method
Who can not have java js code? Reply:
1 js in how there will be a JSP code? JSP code only in the service side ah 2 WEB page using js control refresh timer with setInterval () method
Who can not have java js code?
But that does not mean that there can not be best not to have Are generally loaded js file instead of a separate script (python php or jsp) in write js code Because the script mixed up js code maintenance is extremely inconvenient
And according to your functional requirements to do so is completely impossible to do Because script is run on the server sideAfter a client request to get on the end of the page server can not give Client gets to the script output something script itself is completely invisible This can only be re-initiated request controlled by js A more stupid way is js timed refresh the page but it is equivalent to the user to manually refresh the page the page will flash white what impact the user experience
Recommended to use ajax to achieve
Server to establish a data server via an interface to pass parameters returned by POST or GET json or XML packagejs code to access this interface to obtain updated data Get the data and then use js to render the page using js or modify the DOM
In addition every few milliseconds which is really no reason to increase the pressure on the server has been considered essentially five seconds faster up. . .
No comments:
Post a Comment