1. Bandwidth. I don't want to add the load of the Wikipedia requests to my site.
2. The application does not care about the original retrieval of data from 
wikipedia, just the processed data from the client, using Wikipedia as a data 
source. It could be Flickr as well.
3. Lag. if the client has to wait for me to request the data then send it to 
the client, that'll add lag in something I want as snappy as possible. There us 
a UI that the data is loaded into before it is sent back.

Thanks.


________________________________
 From: Koen Deforche <[email protected]>
To: Jason H <[email protected]>; "[email protected]" 
<[email protected]> 
Sent: Thursday, November 28, 2013 5:06 AM
Subject: Re: [Wt-interest] Easiest way to do AJAX to another site from the 
client?
 


Hey Jason,

You must have a reason why the server cannot simply query Wikipedia?

You can use CORS Ajax calls these days so there is no need for a link. See for 
example the following snippet from Wt.js:

  var crossDomain = 
    (url.indexOf("://") != -1 || url.indexOf("//") == 0) &&
    host(url) != window.location.host;

  function createRequest(method, url) {
    var request = null;
    var supportsRequestHeader = true;
    if (window.XMLHttpRequest) {
      request = new XMLHttpRequest();
      if (crossDomain) {
if ("withCredentials" in request) {
  if (url) {
    request.open(method, url, true);
    request.withCredentials = "true";
  }
} else if (typeof XDomainRequest != "undefined") {
  request = new XDomainRequest();
  if (url) {
    supportsRequestHeader = false;
    try {
      request.open(method, url + '&contentType=x-www-form-urlencoded');
    } catch (err) {
      request = null;
    }
  }
} else
  request = null;
      } else
if (url)
  request.open(method, url, true);
    } else if (!crossDomain && window.ActiveXObject) {
      try {
request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (err) {
try {
  request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err2) {
}
      }
      if (url && request)
request.open(method, url, true);
    }

    if (request && url && supportsRequestHeader)
      request.setRequestHeader("Content-type",
       "application/x-www-form-urlencoded");

    return request;
  }


Regards,
koen



2013/11/27 Jason H <[email protected]>

I need to have the browser query Wikipedia and return the results to the 
WApplication (after some processing in the browser) 
>I've looked into it and Wikipedia would support this via the CORS mechanism.
>
>
>I was going to do some JS and include it then call it with 
>WApplication.doJavaScript(), but I don't see where I can control <link> 
>elements.
>I also have to set the origin header.
>
>
>Thanks!
>
>
>------------------------------------------------------------------------------
>Rapidly troubleshoot problems before they affect your business. Most IT
>organizations don't have a clear picture of how application performance
>affects their revenue. With AppDynamics, you get 100% visibility into your
>Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
>http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
>_______________________________________________
>witty-interest mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/witty-interest
>
>
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to