Git Product home page Git Product logo

marmottajax's Introduction

MarmottAjax

Envoyer et recevoir des informations simplement en JavaScript avec MarmottAjax.

L'AjaxMarmotte de Dimou il est trop bien ! :D — Jeremy

Logo

Exemple simple

Recuperer le contenu d'un fichier "foo.txt" :

marmottajax("foo.txt").then(function(result) {
    alert(result);
});

Exemple Json

Recuperer le contenu du fichier json "marmottes.json" parsé :

marmottajax.json("marmottes.json").then(function(marmottes) {
	console.log(marmottes);
}).error(function(message) {
	console.error(message);
});

Exemple de POST php

Envoyer des données avec la méthode POST :

marmottajax.post({
    url: "post.php",
    options: { marmotte: "Dimou" }
});

post.php :

<?php echo $_POST["marmotte"];

Toutes les options

marmottajax.get({ // OU marmottajax.post|put|delete() OU marmottajax()

    url: "", // obligatoire, peut être abrégé en marmottajax.get(url).then(callback); (voir premier exemple)

    method: "", // GET par defaut ou défini par la fonction appelée

    json: false, // false par defaut, la reponse sera automatiquement parsé si "true"

    options: {} // informations à envoyer en GET ou en POST (dépend de la méthode)

}).then(function(result) {

    // result

}).error(function(message) {

    // message => "404", "invalid json", "unknow" ou `null`

});

License

WTFPL

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.