How to use the jquery.ajax function in jquery

To help you get started, we’ve selected a few jquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mediachain / cccoin / node / frontend / src / auth.js View on Github external
request1.done(function( hh ) {
      console.log('login.request1.done()');

      console.log('got_challenge', JSON.stringify(hh));

      const dd = hh['challenge'];

      const sig = ethUtils.ecsign(ethUtils.sha256(new Buffer(dd)), new Buffer(posting_priv, 'hex'));

      // Send challenge response:
      const request2 = $.ajax({
        dataType: "json",
        url: "/login_2",
        method: "POST",
        data: JSON.stringify({
          the_pub: posting_pub,
          challenge: dd,
          requested_username: requested_username,
          sig: {
            sig_v: sig.v,
            sig_r: sig.r.toString('hex'),
            sig_s: sig.s.toString('hex'),
          },
        })
      });

      request2.done(function( msg2 ) {
github jupyter / notebook / notebook / static-src / services / kernels / kernel.js View on Github external
var qs = $.param(params || {}); // query string for sage math stuff
        if (qs !== "") {
            url = url + "?" + qs;
        }

        this.events.trigger('kernel_starting.Kernel', {kernel: this});
        var that = this;
        var on_success = function (data, status, xhr) {
            that.events.trigger('kernel_created.Kernel', {kernel: that});
            that._kernel_created(data);
            if (success) {
                success(data, status, xhr);
            }
        };

        $.ajax(url, {
            processData: false,
            cache: false,
            type: "POST",
            data: JSON.stringify({name: this.name}),
            contentType: 'application/json',
            dataType: "json",
            success: this._on_success(on_success),
            error: this._on_error(error)
        });

        return url;
    };
github BKWLD / decoy / assets / js / views / task-method.js View on Github external
execute: function(e) {
			e.preventDefault();

			// Vars
			var url = this.$('a').data('action'),
				spinner_template = this.$('.spinner-46').first(),
				spinner = spinner_template.clone().css('opacity', 1);

			// Add a new spinner
			spinner_template.after(spinner);

			// Execute link via AJAX POST
			$.ajax(url, {
				type:'POST',
				dataType: 'JSON'
			})

			// Success
			.done(function(data) {
				spinner.fadeOut(function() {spinner.remove();});
			})

			// Error
			.fail(function() {
				spinner.fadeOut(function() {spinner.remove();});
			});

		}
github hiromaily / go-gin-wrapper / web / frontend_workspace / react / app / react / apilist / top.jsx View on Github external
break
      case 'delete':
        method = 'delete'
        break
      case 'put':
        method = 'put'
        break
      case 'post':
        method = 'post'
        break
      default:
        return
        break
    }

    $.ajax({
      url: encodeURI(url),
      type: method,
      beforeSend: function beforeSend(xhr) {
        xhr.setRequestHeader(hiromaily_header, hiromaily_key)
        xhr.setRequestHeader('Authorization', token)
      },
      //cache    : false,
      crossDomain: false,
      //contentType: contentType,
      dataType:    'json', //data type from server
      data:        sendData
    }).done(function (data, textStatus, jqXHR) {
      switch (mode) {
        case 'getid':
          //console.log(data.ids)
          that.setState({ids: data.ids})
github CenterForOpenScience / osf.io / website / static / js / addonSettings.js View on Github external
_deauthorizeNodeConfirm: function(node) {
        var self = this;
        var url = node.urls.deauthorize;
        var request = $.ajax({
                url: url,
                type: 'DELETE'
            })
            .done(function(data) {
                self.connectedNodes.remove(node);
            })
            .fail(function(xhr, status, error) {
                Raven.captureMessage('Error deauthorizing node: ' + node.id, {
                    extra: {
                        url: url,
                        status: status,
                        error: error
                    }
                });
            });
    },
github Dahlgren / arma-server-web-admin / public / js / app / views / missions / upload.js View on Github external
submit: function () {
    var self = this
    var $form = this.$el.find('form')

    var $uploadBtn = $form.find('button[type=submit]')
    var laddaBtn = Ladda.create($uploadBtn.get(0))
    laddaBtn.start()

    $.ajax('/api/missions', {
      success: function (data) {
        laddaBtn.stop()
        self.render()
      },
      error: function () {
        laddaBtn.stop()
      },
      files: $form.find(':file'),
      iframe: true
    })
  }
})
github webRunes / WRIO-InternetOS / plus.js View on Github external
function loadPlusHtml(){
     var url = importUrl + 'Plus-WRIO-App/widget/plus.htm';
		 $.ajax({
			   url: url,
			   dataType: 'html',
			   success: function(data) {
				 plus_html= data;
	             $('#nav-accordion').append(plus_html);	
		  }
		 });	
}
github voxmedia / autotune / appjs / views / edit_project.js View on Github external
eve.stopPropagation();

    var $btn = $(eve.currentTarget);

    var model = this.model, view = this;
    if ( !$btn.data('template-id') ) { return; }

    var ss_key = $btn.data('template-id');

    var ctrl = this.alpaca.childrenById[$btn.data('target')];
    if( ctrl.getValue().trim().length > 0 ) {
      var msg = 'This will replace the currently associated document. Click "OK" to confirm the replacement.';
      if ( !window.confirm(msg) ) { return; }
    }

    return Promise.resolve( $.ajax({
      type: "POST",
      url: model.urlRoot + "/create_google_doc",
      data: JSON.stringify({ google_doc_id: ss_key }),
      contentType: 'application/json',
      dataType: 'json'
    }) ).then(
      function( data ) {
        ctrl.setValue(data.google_doc_url);
        ctrl.refreshValidationState();
        ctrl.focus();
      },
      function(err) {
        var msg = 'There was an error authenticating your Google account.';
        view.app.view.error(msg);
        logger.error(msg, err);
      }
github ecomfe / san-xui / src / x / components / Recorder.js View on Github external
e.getSendBuffer(function(n) {
                if (n) {
                    y = e.glb = n.json.glb;
                    var i = $.ajax({
                        url: t.url,
                        cache: !1,
                        contentType:
                            'Content-Type: multipart/form-data; boundary=' +
                            n.boundary,
                        dataType: 'text',
                        data: n.buffer,
                        processData: !1,
                        type: 'post'
                    });
                    w.push(i),
                        i.always(function(t) {
                            if (t && 'string' == typeof t) {
                                var n = t.match(/\"corpus\_no\"\:(\d+)/);
                                n && (n = n[1]),
                                    (t = JSON.parse(t)),
github inspirehep / inspire-next / inspirehep / modules / literaturesuggest / static / js / literaturesuggest / literature_submission_form.js View on Github external
getKB: function getKB(kbname) {
      var url = "/api/knowledge/" + kbname + "/mappings?per_page=100";
      var deferred = new $.Deferred();
      $.ajax({
        url: url,
        dataType: "json"
      }).done(function(data) {
        var kb = {};
        $.each(data, function(key, object) {
          kb[object.from] = object.to;
        });
        deferred.resolve(kb);
      });
      return deferred;
    },