$$.ajax not working

Have the following method:

$$.ajax({
type: type,
method: type,
url: API_URL+METHOD,
data: DATA,
dataType: ‘json’,
//async: false,
xhr: function(){
var xhr = new window.XMLHttpRequest();

  	//Upload progress
  	xhr.upload.addEventListener("progress", function(evt){
  	if (evt.lengthComputable) {
  		var porcentaje = Math.floor((evt.loaded/evt.total*100));
  		$$('#txtSincroPorcentaje').html(porcentaje+'%');
  	}
  	}, false);

  	//Download progress
  	xhr.addEventListener("progress", function(evt){
  		if (cancelAjax==1) {xhr.abort();$$("#txtSincroMensaje").html('Cancelado');}

  		if (evt.lengthComputable) 
  		{
  			var porcentaje = Math.floor((evt.loaded/evt.total*100));
  			//$$('#porcSincro').width(porcentaje+'%');
  			console.log('loaded' + evt.loaded + ' - ' + evt.total + ' ');
  			$$('#txtSincroPorcentaje').html(porcentaje+'%');
  			if (porcentaje>0) {$$("#txtSincroMensaje").html('Sincronizando...');}				
  		}
  		else 
  		{
  			//console.log(xhr.getResponseHeader('API-json-size'));
  			//console.log(evt.loaded);
  			total= xhr.getResponseHeader('API-json-size');

  			if (total===null)
  			{
  				$$('#txtSincroPorcentaje').html('');
  				$$("#txtSincroMensaje").html('Sincronizando...');
  			}
  			else 
  			{
  				if (evt.loaded > total)
  				{
  					total = evt.loaded;
  				}

  				var porcentaje = Math.floor((evt.loaded/total*100));
  				console.log('loaded' + evt.loaded + ' - ' + evt.total + ' ');
  				$$('#txtSincroPorcentaje').html(porcentaje+'%');
  				if (evt.loaded>0) {$$("#txtSincroMensaje").html('Sincronizando...');}	
  			}
  		}

  	}, false);

  	xhr.addEventListener('loadend',  function(evt){
  		//alert();
  		//$$("#txtSincroMensaje").html('Finalizado');
  	}, false);
  	return xhr;
  },
  headers: {
  	'Content-Type' : 'application/x-www-form-urlencoded',
  	'Accept' : 'application/x-www-form-urlencoded',
  	'Authorization': 'Basic ' + btoa(API_USERNAME + ':' + API_PASSWORD)
  },
  success: function (data, text) {
  	objdata(data);
  },
  error: function (request, status, error) {
  	$$('.toast').remove();
  	Materialize.toast("error de conexion.", 2000, 'red darken-4 toast-identifier-for-message');
  	objdata(false);
  }});

But console throws “Uncaught TypeError: $$.ajax is not a function”.
How can I use this functionality in F7?

Same as with $.Deferred(); throws “$$.Deferred is not a function”.

$.ajax may help if you are using jquery library

OR

Request/ Ajax

Completely forgot the fact that I could use any jquery library other than F7 has for this.

Too many hours working. Thanks man.

Best if you load less into memory for performance…

Syntax is different in Framework7: (https://framework7.io/docs/request.html)
$$.request(parameters)
$$.request.promise(parameters)

2 Likes