Worklight http adapter questions

后端 未结 5 2090
南方客
南方客 2021-01-14 16:23

2 simple questions :

  1. Do all http requests make thru http adapter do go thru the worklight server first?

  2. If so then does it mean even a http

5条回答
  •  攒了一身酷
    2021-01-14 17:20

    1) Do all http requests make thru http adapter do go thru the worklight server first?

    Yes. Worklight Adapters work by executing JavaScript on the Worklight Server using Mozilla Rhino. You can read more about Adapters in the IBM Worklight Getting Started Modules. Look at Modules 5 and 6 for Adapter specific details. There are also code samples you can try next. The API documentation is in IBM InfoCenter. There is also a Developer Works article that talks about adapters that you may find helpful.

    2) If so then does it mean even a http adapter request to a public web site say a request to yahoo site for a stock price would also go thru worklight server first then next to the yahoo web site?

    Yes.

    I just want to go straight to yahoo web site without the "intermediate" server (i.e. workligth server)

    IBM Worklight ships with jQuery, you can use the ajax method. Here's an example:

    WLJQ.ajax( "http://finance.yahoo.com/d/quotes.csv?s=DOW+MSFT+AAPL+GOOG&f=snl1" )
    .done(function (data) {
        console.log(data);
    });
    

    Note that WLJQ is the namespace for the version of jQuery that Worklight ships. You can use jQuery or $ by doing: var $ = WLJQ; or var jQuery = WLJQ;.

    You should get something like this back:

    "DOW","Dow Chemical Comp",30.89
    "MSFT","Microsoft Corpora",27.37
    "AAPL","Apple Inc.",448.97
    "GOOG","Google Inc.",790.13
    

提交回复
热议问题