GithubHelp home page GithubHelp logo

alite's People

Contributors

chrisdavies avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

alite's Issues

Cross-Origin Request Blocked issue

Hi, i need to get some info from
http://openapi.ro/api/companies/13548146.json
and if i use alite like this:

alite({
url: 'http://openapi.ro/api/companies/13548146.json',  
method: 'get',
dataType: 'jsonp'
}).then(function (result) { console.log(result); });

i get
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://openapi.ro/api/companies/13548146.json. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

but it works with

$.ajax({
    type: 'get',
    url: 'http://openapi.ro/api/companies/13548146.json',
    dataType: 'jsonp',
    success: function(data) {
        console.log(data["state"]);
        }
})

any hints on this

Thanks

Context

Hi, first of all i want to thank you for this great utility, i use it and had no problems with it and i want to ask you if there is some way to add the context for this keyword, here is an example:
`var a = function () {
alite({
url: '/api/foo/bar',
method: 'POST',
data: { foo: 'bar' }
}).then(function (result) {
this.process(result);
})
}
a.prototype = {
process: function(result) {
... do something with the result ...
},
....

}`
this.process is not available so i have to assign a new variable to this "var _this = this; " and call the _this.process(value). is there any way i can pass the scope without creating this new variable?
Thanks

POST simple data

Hi, i didn't get a change to thank you for your help and responses ๐Ÿ‘ and here i am with another question, is it possible to post simple data say a=1 without creating a FormData() or sending json array?
For now i do this:

var data = new FormData();
data.append('a','1');
alite({
     url: url,
     method: 'post',
     data: data,
     raw: true
});

and if i try to send
data = "a=1";
I get a post request without name and value "a=1"
Thanks

multipart/form-data

Hi, i have added a multipart/form-data to a test project (it has some text inputs and one file input) and i am using this function onsubmit

function post(url,form) {
  var data = new FormData(form);
  return alite({
                url: url,
                method: 'post',
                data: data,
                raw: true
            });
}

is this the right way to do this or do i have to specify Content-Type, Content-Disposition ...
Thank you

Loading while retrieving data

Hi, I've added one loading element to my page and i want to display it while waiting for response,
I am using alite.min.js and i change it like this:

//to show my element PSI.Utils.loading is a simple function that hide/show my loading element
new Promise(function(n,r){PSI.Utils.loading(true);var s=... 

//to hide my loading element
s.onreadystatechange=function(){4==s.readyState&&(s.status>=200&&s.status<300?(n(a(s)),PSI.Utils.loading(false)):r(a(s)),(PSI.Utils.curl.ajaxStop||t)(s,e))}

Is this correct? Or is there a better way to do this?
The problem is that it won't hide for 404's responses... I could do that:

s.onreadystatechange=function(){4==s.readyState&&(s.status>=200&&s.status<300?(n(a(s)),PSI.Utils.loading(false)):(r(a(s),PSI.Utils.loading(false))),(PSI.Utils.curl.ajaxStop||t)(s,e))}

but it doesn't seem OK to me :)
Thanks

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.