+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Client side data processing

  1. #1
    cybrax's Avatar
    cybrax is offline x10 Elder cybrax is on a distinguished road
    Join Date
    Aug 2009
    Location
    UK
    Posts
    699

    Client side data processing

    Using your web site hosting server to retrieve and mashup data from other web sites is rapidly becoming an "Old School" technique. ( and of course some web hosts are making it nigh on impossible )

    So there is a growing trend nowdays to move this CPU intensive work away from the central server and onto the clients PC which is typically doing very little. Android apps are a good example of this in action with mobile devices.

    Sadly asking a vistor to download and run an exe file before they can view your website is unlikey to ever be a popular even with the non tech savvy at least for now anyhow.

    That leaves us with only ActiveX ( XMLHTTP requests ) which only works with IE. Though vaugely remember a plugin being available for Firefox. Not as versatile as cURL but may be useful for some.

    The trick of course is NOT to use the ActiveX component for every single vistor (unless the output mashup requires this) but rather to have just one visitor an hour/day/week upload the scraped data to a server side cache where all can see it regardless of browser type or security settings.

    OK, schools out now go play

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head></head>
    <body>
    <div id="stats">STANDBY - nb: this only works for IE, accept the ActiveX request. </div>
    
    <script>
    
    function processStateChange(){
      statusDiv = document.getElementById("stats");
      if (req.readyState == 0){ statusDiv.innerHTML = "WAKING UP"; }
      if (req.readyState == 1){ statusDiv.innerHTML = "GETTING THERE"; }
      if (req.readyState == 2){ statusDiv.innerHTML = "GOT IT!"; }
      if (req.readyState == 3){ statusDiv.innerHTML = "TINKERING"; }
      if (req.readyState == 4){
        statusDiv.innerHTML = "ALL DONE";
    
    
    
        var data = req.responseText;  <!-- put html into javascript variable-->
    
                                               <!--do something with string -->
    
           document.write (data);                     <!--output data -->
    
    
    
        }
    }
    
    req = new ActiveXObject("Msxml2.XMLHTTP");
    if (req) {
        req.onreadystatechange = processStateChange;
        req.open("GET", "http://www.google.co.uk/search?q=car", true);
        req.send();
    }
    
    </script>
    
    </body>
    </html>
    The code must flow.
    Project 157: Latest UK Jobs direct to your mobile phone
    New Domain under construction: Lovelogic.net
    home for some new projects that we can't keep here ;)


  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Client side data processing

    Modern browsers have an XMLHttpRequest object, including IE since version 7, which supports the same API. Fallback to Msxml2.XMLHTTP is only necessary on IE 5 through 6.

  3. #3
    cybrax's Avatar
    cybrax is offline x10 Elder cybrax is on a distinguished road
    Join Date
    Aug 2009
    Location
    UK
    Posts
    699

    Re: Client side data processing

    Quote Originally Posted by misson View Post
    Fallback to Msxml2.XMLHTTP is only necessary on IE 5 through 6.
    Unfortunately IE6 is far from being dead even now, as of last year (2009) it was still commanding a sizeable percentage of visitors browsers so it is allways a good practice to provide 'legacy support'.

    Updated browser stats from W3Counter:

    1 Internet Explorer 8 27.01%
    2 Firefox 3.6 24.22%
    3 Internet Explorer 7 9.34%
    4 Chrome 6 6.91%
    5 Internet Explorer 6 5.24%
    6 Safari 5 4.46%
    7 Chrome 7 4.38%
    8 Firefox 3.5 3.41%
    9 Firefox 3 1.86%
    10 Safari 4 0.92%
    Last edited by cybrax; 11-14-2010 at 07:49 AM.
    The code must flow.
    Project 157: Latest UK Jobs direct to your mobile phone
    New Domain under construction: Lovelogic.net
    home for some new projects that we can't keep here ;)


  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Client side data processing

    I really don't get your point.

    Are you saying that you want to run a XMLHttp Request from a web page that will download content from another site to a users machine, have that machine process the results, and then use another XMLHttp Request to upload the processed data to your server?
    Nothing is always absolutely so.

  5. #5
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Client side data processing

    Using your web site hosting server to retrieve and mashup data from other web sites is rapidly becoming an "Old School" technique. ( and of course some web hosts are making it nigh on impossible )
    I don't see why you think it is 'old-school'. PHP can be used to process data with a very high efficiency, not as great as you'd get with a full compiled script, but it is comparatively pretty good. Javascript, on the other hand, is not really designed to do any data intensive work on the client side and doing so may cause your user's browser to lock up or crash. Whilst there are new techniques that avoid this problem (WebWorkers), it still doesn't change the fact that you are trying to do something in Javascript that could be handled with considerably greater efficiently on the server. Either way, farming a data task out to a user is just asking for trouble.
    Whilst the new block on port 80 here might seem frustrating, it is mainly there to boost the servers speed by blocking proxies.

    Also, this should not work:
    req.open("GET", "http://www.google.co.uk/search?q=car", true);
    Any browser that does allow it to work is breaking the JS rule for cross-site access; all http requests must go to only the same domain and port as the original page was loaded from.

  6. #6
    cybrax's Avatar
    cybrax is offline x10 Elder cybrax is on a distinguished road
    Join Date
    Aug 2009
    Location
    UK
    Posts
    699

    Re: Client side data processing

    That's pretty much the idea, get a visitor to perform the 'gathering' and then save the information server side where it re-used as part of another web page(s) Of course passing the processed information back to a server would probably be simpler to achieve with a hidden form field but you have the general gist.
    The code must flow.
    Project 157: Latest UK Jobs direct to your mobile phone
    New Domain under construction: Lovelogic.net
    home for some new projects that we can't keep here ;)


  7. #7
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Client side data processing

    How do you get around the cross-domain problem?

    Not to mention an irate user who finds out what you've done.
    Nothing is always absolutely so.

  8. #8
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Client side data processing

    How do you get around the cross-domain problem?
    Ideally you shouldn't be able to on the client side, but it would appear that IE is letting it through. I believe jQuery also has support to get around it, but it uses a small piece of flash to do so.

  9. #9
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Client side data processing

    Quote Originally Posted by cybrax View Post
    Quote Originally Posted by misson View Post
    Fallback to Msxml2.XMLHTTP is only necessary on IE 5 through 6.
    Unfortunately IE6 is far from being dead even now, as of last year (2009) it was still commanding a sizeable percentage of visitors browsers so it is allways a good practice to provide 'legacy support'.
    I don't see how that's relevant to my comment. I was saying to try to use Msxml2.XMLHTTP only if XMLHttpRequest doesn't exist.

  10. #10
    cybrax's Avatar
    cybrax is offline x10 Elder cybrax is on a distinguished road
    Join Date
    Aug 2009
    Location
    UK
    Posts
    699

    Re: Client side data processing

    Easy there lads, the object of the excercise is how to utilise the resources (internet connection and processing power) of the web site visitors own PC.

    Not beat each other to death with the sacred manuals.

    Lemon Tree.. did come across one article about using Jquery but it still relies on PHP+ cURL to do the intial 'grabbing' of data. Though this does very much look like the way to go.

    http://www.redbonzai.com/blog/web-de...-page-content/
    The code must flow.
    Project 157: Latest UK Jobs direct to your mobile phone
    New Domain under construction: Lovelogic.net
    home for some new projects that we can't keep here ;)


+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. [jQuery] Client Data
    By Shadow121 in forum Programming Help
    Replies: 0
    Last Post: 08-25-2010, 10:38 PM
  2. Data Base data for blog destroyed
    By metahive in forum Free Hosting
    Replies: 1
    Last Post: 08-14-2010, 10:34 PM
  3. The Other Side Up - Web magazine
    By shant93 in forum Review My Site
    Replies: 6
    Last Post: 07-21-2010, 09:03 PM
  4. Just a little side business..
    By frillypinkmonster in forum Review My Site
    Replies: 12
    Last Post: 05-16-2010, 01:11 AM
  5. Ads on the Side Bar
    By a94060 in forum Feedback and Suggestions
    Replies: 3
    Last Post: 01-05-2010, 03:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers