FineUploader onComplete event not called - php

It's happening something quite strange to me. I'm trying to use this plugin, at friday I saw working it completelly fine.
But I don't know what happened... the onComplete event is not firing. I had tested several ways to define it, these:
var fineUploader = $('#fineUploader');
fineUploader.fineUploader({
request:{
endpoint: '/wp-content/plugins/innovation-factory/includes/php/endpoint.php'
},
callbakcs:{
onComplete: function(id, name, responseJSON, xhr){
console.log(responseJSON);
debug.log({
_id: id,
_name: name,
_responseJSON: responseJSON,
xhr
});
}
},
onComplete: function(id, name, responseJSON, xhr){
console.log(responseJSON);
debug.log({
_id: id,
_name: name,
_responseJSON: responseJSON,
xhr
});
}
});
fineUploader.on('onComplete', function(id, name, responseJSON, xhr){
console.log(responseJSON);
debug.log({
_id: id,
_name: name,
_responseJSON: responseJSON,
xhr
});
});
I had tested theese 3 ways one by one, separatly.
What I'm doing wrong?
PD: There is no errors in console, and the files are correctly saved...

The issue with your code is only caused by the fact that you spells "callbacks" wrong. If you fix your spelling error, the issue disappears.

Related

How to make Typeahead.js search a specific DB (of multiple) in Laravel 5.7

I have 2 databases in my Laravel 5.7 app, and I would like to add a typeahead functionality with one of them.
It is the first time I use it, so I don't really know how to do it.
I'm following the instructions here: https://itsolutionstuff.com/post/laravel-57-autocomplete-search-from-database-using-typeahead-jsexample.html
I have used typeahead in my application. Hope this would help you.
$(document).ready(function(){
$.ajax(
{
type : 'GET',
url: base_url+"/getrelateduser",
success: function (data)
{
// Defining the local dataset
var relateduser = data;
// Constructing the suggestion engine
var relateduser = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: relateduser
});
$('.sendleads').typeahead({
hint: true,
highlight: true, /* Enable substring highlighting */
minLength: 3, /* Specify minimum characters required for showing result */
},
{
name: 'relateduser',
source: relateduser
});
}
});
});
Here the url "/getrelateduser" will return all the emails of users in the users table. Let me know if you have more queries.

Jquery autocomplete with post data

I have a script with autocomplete, get some data from an external source according to searched term.
I can output the json in the console but I'm struggling to pass it to the response, how do I do that?
$('#test').autocomplete({
source: function(request,response){
$.post('/schoollookup', {
query: request.term
}, function(data){
}, 'json'
);
},
minLength: 2
});
$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});
This is the syntax for post request. where
url : A string containing the URL to which the request is sent.
data : A plain object or string that is sent to the server with the request.
success : callback function
#Sumesh
$.post('/schoollookup', {
should be working the same, the difficulty that I have is to get response
Thank you for your answer r007ed, the issue was that it was not returning an array.
So the final code for this is :
$('#test').autocomplete({
source: function(request,response){
$.post('/schoollookup',{query: request.term}, response, 'json');
},
minLength: 2
});

505 / cancel status with jquery ajax (Codeigniter)

Working with jquery ajax in Codeigniter framework.
Sending ajax request as below (onclick of a button)
$.ajax({
type: "POST",
url: "user_registration",
data: {
first_name: first_name,
middle_name: middle_name,
last_name: last_name,
position: position,
company_name: company_name,
address_line1: address_line1,
address_line2: address_line2,
phone_number: phone_number,
fax_number: fax_number,
mobile_number: mobile_number,
email_id: email_id,
company_website: company_website,
username: username,
password: password,
news_letter: news_letter
},
cache: false,
success: function (result) {
$("#please_wait").hide();
$("#registration_results").html(result);
},
error: function (xhr) {
console.log("Error: " + xhr.statusText);
}
});
Possible solutions i found in different forums are as below
CSRF security should be disabled (Changed TRUE to FALSE in config file)
Tried to send the request with dataType:jsonp and also with dataType:json.
As i am using onclick method placed return false at the end of the function.
used security->get_csrf_token_name() ?> : 'security->get_csrf_hash() ?> in data{}.
I tried with all the above ways. But still i am getting 505 / cancel status.
Note : Previously (some couple of days back) this code is working fine, but now it is giving trouble. Ajax requests with the same format in other pages are working fine.
Please suggest me what may be the problem.
Thanks sreeram,

jQuery UI AutoComplete with multiple cells

I need some help with jQuery UI autocomplete function.
I have one cell which has class, and I have a working autocomplete in it right now.
$("[class*='enari']").autocomplete({
source: "getproductnow.php",
autoFocus: true,
minLength: 2,
dataType: "json",
select: function(event, ui) {
$('#tuote').val(ui.item.value);
},
open: function(event, ui){
$("ul.ui-autocomplete li a").each(function(){
var htmlString = $(this).html().replace(/</g, '<');
htmlString = htmlString.replace(/>/g, '>');
$(this).html(htmlString);
});
}
});
Where the problem comes is the situation where script adds by "document.createElement('div');" a new input field which has same name and autocomplete is not anymore working.
I need to have autocomplete working with "running numbers (1,2,3,4,5,6 and so on...)". Is it even possible and how?
Sorry for my rough language and thank you for your answers!

JQueryUI Autocomplete - Trigger on all events

I'm using JQuery UI Autocomplete to pull records from a caller database. This works fine for records that are in the database but I want to improve handling for new records.
For example, if a user chooses a name from a suggestion, I use the return id later in the form. This works fine. If the value is not found in suggestions I am struggling to trigger the script since it is currently triggered from a select event, and there doesn't appear to be a onblur event for this function which I think is what I'm after. I'm new to JQuery and have already spent a day trying to sort it.
Code so far is:
$("#contact_name").autocomplete({
source: "get-caller-names.php",
minLength: 2,
select: function(event, ui) {
$('#contact_id').val(ui.item.id);
$('#contact_name').val(ui.item.name);
$('#contact_email').val(ui.item.email);
$('#contact_phone').val(ui.item.phone);
$('#contact_addr').val(ui.item.address);
}
});
All suggestions welcome, thanks.
Code in case others have the same issue...
// auto-suggest jqueryui
$("#contact_name").autocomplete({
source: "GetCallerNames.php",
minLength: 2,
select: function(event, ui) {
$('#contact_id').val(ui.item.id);
$('#contact_name').val(ui.item.name);
$('#contact_email').val(ui.item.email);
$('#contact_phone').val(ui.item.phone);
$('#contact_addr').val(ui.item.address);
},
change: function(event, ui) {
$.ajax({
type: 'GET',
url: 'GetCallerNames.php',
dataType: 'json',
data: {term:$(this).val()},
success: function(data) {
if (data!=null&&data!='') {
$('#contact_id').val(data[0].id);
$('#contact_email').val(data[0].email);
$('#contact_phone').val(data[0].phone);
$('#contact_addr').val(data[0].address);
}
}
});
}
});
Could you not add a new handler for change eg:
$( ".selector" ).autocomplete({
select: function(event, ui) { ... },
change: function(event, ui) { ... }
});

Categories