Giter Site home page Giter Site logo

coderfin / byutv-jsonp Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 2.0 2.49 MB

The byutv-jsonp element (<byutv-jsonp>) exposes network request functionality. It is a Polymer v1.0+ element that facilitates making JSONP requests. It uses Polymer behaviors (Byutv.behaviors.Jsonp). It is patterned after Polymer's iron-ajax element (<iron-ajax>). It has been tested using unit tests. It is part of the BYUtv Elements group of elements.

Home Page: http://coderfin.github.io/byutv-jsonp/components/byutv-jsonp/

License: MIT License

HTML 10.94% JavaScript 83.58% CSS 5.48%

byutv-jsonp's People

Contributors

coderfin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

byutv-jsonp's Issues

No on-response / last-response trigger

Hey all,

not sure wether it should be posted here or not, but I'm not getting a response trigger from the byutv.
It does fetch the data correctly trough as seen trough google dev mode.

Any idea's ?

<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../polymer-app/shared-styles.html">

<dom-module id="contact-pagina">
 <template>
 <style include="shared-styles">
 :host {
 display: block;
 }
 </style>


  <byutv-jsonp
    auto
    id="ajax_members_get"
    method="GET"
    url="https://api.guildwars2.com/v2/guild/code/members"
    params='{"access_token":"code"}'
    handle-as="json"
    last-response="{{_c_studenten}}"
    on-response="members_get_response_handler">
  </byutv-jsonp>



 </template>
 <script>
 Polymer({
 is: 'contact-pagina',
 properties: {
   c_visible: {
     type: Boolean,                                      /* true when element is the active visible item */
     value: false,
     observer: '_initializing',
   },
 },
 _initializing : function() {
   if (this.c_visible) {
      console.log("about-pagina");
      this.members_get_request_handler();
   }
 },
 members_get_request_handler: function() {
   console.log("members_get_request_handler");
   this.$.ajax_members_get.contentType="application/json";
   this.$.ajax_members_get.body={
   };
   this.$.ajax_members_get.generateRequest();
 },

 members_get_response_handler: function(request) {
   console.log("members_get_response_handler aantal studenten="+request.detail.response.length);
   this._c_studenten = request.detail.response;
 },
 });
 </script>
</dom-module>

Callback undefined when requesting too fast

Hi,

Im having some troubles using this component. I need to do 2 request to the Instagram API:

<!-- Instagram API -->
    <byutv-jsonp
        id="requestPosts"
        url="https://api.instagram.com/v1/users/self/media/recent/"
        params="{{posts_params}}"
        on-response="_posts_response"
        >
    </byutv-jsonp>

     <byutv-jsonp
        id="requestComments"
        url="https://api.instagram.com/v1/media/{{post_id}}/comments"
        params="{{posts_params}}"
        on-response="_comments_response"
        >
    </byutv-jsonp>

The first one works well as its only generated once at the start. But the other one is generated within a loop:

for (var i=0; i < ARRAY.length ; i++) { ... this.$.requestComments.generateRequest(); };

When requesting using the same too many times too fast im getting the "callback is not defined" error therefore i cant get the data from the API.

The callback functions (_posts_response and _comments_response works well the first time so they are not the problem).

Do you have any idea of whats happening? Am i using it right?

Thank you!!

Basic Authentication using byutv-jsonp

I had been passing the credentials for Basic Authentication via the headers attribute of iron-ajax.

'{"Authorization": "Basic ' + btoa("test" + ":" + "test") + '"}'

However, this does not seem to work with the byutv-jsonp element. And neither passing the username and password via URL (i.e. test:[email protected]) works.

Is there another way to use Basic Auth with this element?

Uncaught SyntaxError: Unexpected token : (not getting response in on-response method)

i am getting this error even when the api call goes through successfully with status 200 but i donot get response in on-response method.

i am calling the component like this -
byutv-jsonp handle-as="json" id="getLocation" method="GET" on-
response="_handleGetLocationResponse" debounce-duration="300"

and this is how i am invoking the ajax-request -
var ajax = this.$.getLocation;
ajax.url = "https://maps.googleapis.com/maps/api/place/autocomplete/json";
ajax.params = {
'components': 'country:IN',
'key': 'Bryurhdfh4656gnhjngfhnfghfgh',
'input': e
};
ajax.generateRequest();

imageedit_1_3713663134

How can this be solved?

Handling html response

Thank you for a great element! Is it possible to extend it to also be able to handle html/xml response data, e.g. using handle-as="xml"?

Custom headers

Ho do we send across custom headers like Authorization along with the request?

Safari Error event

The Error event is not getting fired when server responds with html in Safari. But works just fine in Chrome though.

The script tag attached to the head runs into compilation error with Safari there by nothing proceeding beyond that. Working with Google AppScript so no control on the server returns.

Two way binding fails

Hey there, I tried to use data binding in the params area but it completely failed. Any ideas?

How to solve Uncaught SyntaxError: Unexpected token : ?

<byutv-jsonp
  auto
  url="https://ajax.googleapis.com/ajax/services/search/news?v=1.0&rsz=8&pz=1&cf=all&ned=in&hl=en&topic=tc"
  debounce-duration="300"
  callbackKey = "callback"
  last-response="{{lastResponse}}"
  last-error="{{lastError}}"></byutv-jsonp>

This looks like very simple right? but it throws below error

Uncaught SyntaxError: Unexpected token :

How to solve this ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.