Ir al contenido principal

jQuery V (Ajax)

AJAX


Consolidation

In a different js

var data_service = function () {

   ajaxService = function () {
     return $.ajax({
       url : "",
       data : {}
     })
   }

 return {
    ajaxService : ajaxService,
   ajaxService2 : ajaxService
  }

}();


Multiple Calls

$.when( ajaxService, ajaxService2 )
  .done( function(ajax_data, ajax_data2 ){
   
    var  result = ajax_data[0];

  })

Apply
To pass an array

var promises = [ajaxService, ajaxService2]
$.when.apply($, promises);

Other example
 var requests = [

            this.load_graph_lte("dashboard_LTE_KPI", 'main', 'LTE_RRC_Setup_SR'),
            this.load_graph_lte("dashboard_LTE_KPI", 'graph2', 'LTE_Session_Abnormal_Release_Rate'),
            this.load_graph_lte("dashboard_LTE_KPI", 'graph3', 'RRC_Connected_Users'),
            this.load_graph_lte("dashboard_LTE_KPI", 'graph4', 'LTE_Retention_Rate'),
            this.load_graph_lte("dashboard_LTE_KPI", 'graph5', 'LTE_DLUser_Throughput'),
            this.load_graph_lte("dashboard_LTE_KPI", 'graph6', 'LTE_ULUser_Throughput')
        ];

        $.when.apply($, requests).done(function () {
            hide();
        })

load_graph_lte(service, html_div, kpi) {


        return $.ajax({
            method: "GET",
            url: service,
            contentType: "application/json",
            data: {
                kpi: kpi
            }
        }).done(function (data_ajax) { .....  });
Add Header

$.ajax({
  url:
  data: 
  beforeSend: function( request ){
      request.setRequestHeader("AuthToken" , authToken )
  }
})

Receive the header

.sucess( function(data, statusText, jqXHR){
     jqXHR.getResponseHeader("AuthToken");
})


AJAX Converter

General converter go on ajaxSetup

$.ajaxSetup({

    converters : {
    "json destine_format" : function (data){
    return data && data.hasOwnProperty("my_property") ? data.my_property : data;
    }
    }

})


To use:

$.ajax({
  url:
  dataType: "destine_format",
  success : function (data) {
    //now contains only data.my_property
  }

});



Data

Set the data
$('your_filter').data("name_data", value_data);

Get data
$('your_filter').data("name_data");



Attribute

Set the data
$('your_filter').attr("name_data", value_data);

Get data
$('your_filter').attr("name_data");



Comentarios

Entradas populares de este blog

Android - Basic Steps (Notifications)

User Notifications Types: Toast Notification Area Notifications Tip To use the notification vibration, establish the permission in the AndroidManifest.xml file    <uses-permission android:name="android.permission.VIBRATE" >     </uses-permission> Broadcast Base class for components that receive and react to events When event occur is represented as Intent, then are broadcast to system The Intent routes to BroadcastReceiver The BroadcastReceiver receive on the method onReceive() Broadcast Events can be broadcast in Order or Normal way Normal - Undefined order and if there are two or more BroadcastReceivers can process the event at the same time. Order - Deliver the intent one at the time in priority order Can also be Sticky or Not Sticky Sticky   Store intent after initial broadcast Is useful to record system changes like the battery status Is disposed after the event finish  Non Stick...

TOGAF9

Kinds of Architectures Business Architecture / Business Process Architecture    Define the business strategy, governance, organization and key business processes Data Architecture    Describe the structure of an organization logical and physical data assets and data resources Application Architecture    Describe a blueprint for the individual application systems to be deploy, interactions and  their relationships to the core business processes of the organization Technology Architecture    Describe the logical software and hardware capabilities that are required to support the deployment of business data and application services. This includes middle-ware infrastructure, networks, communications, processing standards  Architecture Governance Increase transparency of accountability, and informed delegation of authority Controlled risk management Protection of the existing asset base through maximizing  re-us...

BI - SSIS ( Basics I )

SSIS - Basic Concepts Tasks Bulk Insert Task—Loads data into a table by using the BULK INSERT SQL command. Data Flow Task—This is the most important task that loads and transforms data into an OLE DB Destination. Execute Package Task—Enables you to execute a package from within a package, making your SSIS packages modular. Execute Process Task—Executes a program external to your package, like one to split your extract file into many files before processing the individual files. Execute SQL Task—Executes a SQL statement or stored procedure. File System Task—This task can handle directory operations like creating, renaming, or deleting a directory. It can also manage file operations like moving, copying, or deleting files. FTP Task—Sends or receives files from an FTP site. Script Task—Runs a set of VB.NET or C# coding inside a Visual Studio environment. Send Mail Task—Sends a mail message through SMTP. Analysis Services Processing Task—This task processes a SQL Server A...