Skip to content

Instantly share code, notes, and snippets.

@CarlosDanielDev
Last active January 23, 2019 22:58
Show Gist options
  • Save CarlosDanielDev/864f827d7807e84383fba0158c9c11da to your computer and use it in GitHub Desktop.
Save CarlosDanielDev/864f827d7807e84383fba0158c9c11da to your computer and use it in GitHub Desktop.
Uncaught TypeError: Illegal invocation
at add (jquery.js:8260)
at buildParams (jquery.js:8247)
at buildParams (jquery.js:8241)
at buildParams (jquery.js:8241)
at buildParams (jquery.js:8241)
at buildParams (jquery.js:8241)
at Function.jQuery.param (jquery.js:8280)
at Function.ajax (jquery.js:8866)
at HTMLButtonElement.<anonymous> (funcoes.js:6855)
at HTMLDocument.dispatch (jquery.js:5110)
$(function(){
$(document).on('click', '#add_certi', function(){
let array;
let idLote = $('#id_lote').val();
let idUnidade = $('#id_unidade').val();
let idGrupo = $('#id_grupo').val();
$("#loader").show().fadeTo('fast', 1);
$('#add_certificado').fadeTo( "slow" , 0.15);
array = $('input:checked').map(function(){
return this.value;
});
$.ajax({
type:"POST",
url: '/vincula-certificado',
data:{array, idLote, idUnidade, idGrupo},
success: function(result){
$("#loader").hide();
$('#add_certificado').fadeTo("slow", 1);
}
});
});
});
// Serialize an array of form elements or a set of
// key/values into a query string
jQuery.param = function( a, traditional ) {
var prefix,
s = [],
add = function( key, valueOrFunction ) {
// If value is a function, invoke it and use its return value
var value = jQuery.isFunction( valueOrFunction ) ?
valueOrFunction() ://AQUI ELE ME RETORNA O ERRO DE ILLEGAL INVOCATION
valueOrFunction;
s[ s.length ] = encodeURIComponent( key ) + "=" +
encodeURIComponent( value == null ? "" : value );
};
// If an array was passed in, assume that it is an array of form elements.
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
// Serialize the form elements
jQuery.each( a, function() {
add( this.name, this.value );
} );
} else {
// If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
}
}
// Return the resulting serialization
return s.join( "&" );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment