<commit_before>(function(Spine, $){
  
var Model = Spine.Model;
var Ajax  = Spine.Ajax = {
  getUrl: function(object){
    if (!(object && object.url)) return null;
    return((typeof object.url === "function") ? object.url() : object.url);
  },

  methodMap: {
    "create":  "POST",
    "update":  "PUT",
    "destroy": "DELETE",
    "read":    "GET"
  },

  send: function(record, method, params){ 
    params = $.extend(params || {}, {
      type:          this.methodMap[method],
      contentType:  "application/json",
      dataType:     "json",
      data:         {}
    });
    
    if (method === "create" && record.model)
      params.url = this.getUrl(record.parent);
    else
      params.url = this.getUrl(record);

    if ( !params.url ) throw("Invalid URL");
    
    if (method === "create" || method === "update") {
      var data = {};
    
      if (record.parent.ajaxPrefix) {
        data = {};
        data[record.parent.ajaxPrefix] = record;
      } else {
        data = record;
      }
      data = $.extend(data, params.data);
      params.data = JSON.stringify(data);
      params.processData = false;
    
      params.success = function(data, status, xhr){
        if ( !data ) return;
      
        // Simple deep object comparison
        if (JSON.stringify(record) === JSON.stringify(data)) return;
      
        // ID change, need to do some shifting
        if (data.id && record.id != data.id) {
          var records      = record.parent.records;
          records[data.id] = records[record.id];
          delete records[record.id];
          record.id        = data.id;
        }
      
        // Update with latest data
        Ajax.noSync(function(){ 
          record.updateAttributes(data); 
        });
      
        record.trigger("ajaxSuccess", record, status, xhr);
      };
    }
  
    if (method === "read" && !params.success)
      params.success = function(data){
       (record.refresh || record.load).call(record, data);
      };
  
    var success = params.success;
    params.success = $.proxy(function(){
      if (success) success.apply(this, arguments);
      this.sendNext();
    }, this);
  
    params.error = function(xhr, s, e){
      record.trigger("ajaxError", record, xhr, s, e);
    };
  
    $.ajax(params);<commit_msg>keep sending requests after an ajax error - developers can choose to catch errors and prevent additional requests (return false)<commit_after>(function(Spine, $){
  
var Model = Spine.Model;
var Ajax  = Spine.Ajax = {
  getUrl: function(object){
    if (!(object && object.url)) return null;
    return((typeof object.url === "function") ? object.url() : object.url);
  },

  methodMap: {
    "create":  "POST",
    "update":  "PUT",
    "destroy": "DELETE",
    "read":    "GET"
  },

  send: function(record, method, params){ 
    params = $.extend(params || {}, {
      type:          this.methodMap[method],
      contentType:  "application/json",
      dataType:     "json",
      data:         {}
    });
    
    if (method === "create" && record.model)
      params.url = this.getUrl(record.parent);
    else
      params.url = this.getUrl(record);

    if ( !params.url ) throw("Invalid URL");
    
    if (method === "create" || method === "update") {
      var data = {};
    
      if (record.parent.ajaxPrefix) {
        data = {};
        data[record.parent.ajaxPrefix] = record;
      } else {
        data = record;
      }
      data = $.extend(data, params.data);
      params.data = JSON.stringify(data);
      params.processData = false;
    
      params.success = function(data, status, xhr){
        if ( !data ) return;
      
        // Simple deep object comparison
        if (JSON.stringify(record) === JSON.stringify(data)) return;
      
        // ID change, need to do some shifting
        if (data.id && record.id != data.id) {
          var records      = record.parent.records;
          records[data.id] = records[record.id];
          delete records[record.id];
          record.id        = data.id;
        }
      
        // Update with latest data
        Ajax.noSync(function(){ 
          record.updateAttributes(data); 
        });
      
        record.trigger("ajaxSuccess", record, status, xhr);
      };
    }
  
    if (method === "read" && !params.success)
      params.success = function(data){
       (record.refresh || record.load).call(record, data);
      };
  
    var success = params.success;
    params.success = function(){
      if (success) success.apply(Ajax, arguments);
      Ajax.sendNext();
    };
  
    params.error = function(xhr, s, e){
      record.trigger("ajaxError", record, xhr, s, e);
      Ajax.sendNext();
    };
  
    $.ajax(params);
{'fraction_non_alphanumeric': 0.15466326747397494, 'fraction_numerical': 0.0, 'mean_word_length': 2.051198963058976, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7084189', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1405, 'n_words': 319}