Autcomplete error "Uncaught typeError"

More
3 years 1 week ago #109821 by jorge_acevedo
jorge_acevedo created the topic: Autcomplete error "Uncaught typeError"
Hi!

I've been using the autocomplete for quite a while already but for some reason it has stopped working. I went to the limesurvey workarounds manual and updated the script I was using but still get the following error:

fullArray = $.csv.toArrays(data);
Uncaught TypeError: Cannot read property 'toArrays' of undefined.


Thanks for your help!!


The whole code I am using is the following:


<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

// Define the CSV filename
var csvName = 'fsa.csv';

// Define some paths
var surveyRoot = location.pathname.split('index.php')[0];
// var templateName = $('head link[href*="template.css"]').attr('href').replace(/\/template.css/, '').split('/templates/')[1];
var csvPath = surveyRoot+'autocomplete/';

// Define the questions
var q1ID = '{QID}';
var q1 = $('#question'+q1ID);
// var q2 = $(q1).nextAll('.text-short:eq(0)');
// var q3 = $(q1).nextAll('.text-short:eq(1)');

// Define the path to the CSV
var url = csvPath+csvName;

// Create an array to hold the CSV rows
var namesArr = new Array();

// Grab the CSV contents
$.get( url, function( data ){

// Convert CSV contents to an array of arrays
fullArray = $.csv.toArrays(data);
// Load the CSV rows array
$(fullArray).each(function(i, item){
namesArr.push(item[0]);
});

// Initialise the autocomplete plugin
$('input.text', q1).autocomplete({
source: namesArr,
});
});
});
</script>

Please Log in to join the conversation.

More
3 years 1 week ago #109862 by tpartner
tpartner replied the topic: Autcomplete error "Uncaught typeError"
It doesn't look like the CSV contents are being imported correctly.

What changes were made to the installation before the error appeared?


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
3 years 1 week ago #109894 by jorge_acevedo
jorge_acevedo replied the topic: Autcomplete error "Uncaught typeError"
Hi Tony,
Thanks for your response.

I just updated limesurvey. I also changed the survey template. But I moved everything as it should be. And I don't get an error of not finding the csv.

I'll provide a link to a test question later today for you to look at.

Thanks!

Please Log in to join the conversation.

More
3 years 1 week ago #109896 by jorge_acevedo
jorge_acevedo replied the topic: Autcomplete error "Uncaught typeError"

Please Log in to join the conversation.

More
3 years 1 week ago #109905 by jorge_acevedo
jorge_acevedo replied the topic: Autcomplete error "Uncaught typeError"
And this is the link of the file....

gbresearch.net/research/autocomplete/fsa.csv

Please Log in to join the conversation.

More
3 years 1 week ago - 3 years 1 week ago #109924 by tpartner
tpartner replied the topic: Autcomplete error "Uncaught typeError"
A couple of things to check...

1) This line should have a lower-case v in "Var"
Var url = "research/autocomplete/fsa.csv";

2) Because you are using a subdomain, the URL defined in that line leads to research.gbresearch.net/research/autocomplete/fsa.csv which doesn't exist. I think the defined URL should simply be "autocomplete/fsa.csv".


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 3 years 1 week ago by tpartner.

Please Log in to join the conversation.

More
3 years 1 week ago - 3 years 1 week ago #109943 by jorge_acevedo
jorge_acevedo replied the topic: Autcomplete error "Uncaught typeError"
I changed it as suggested but still not working.

Any more suggestions?

I would think it stopped working when we changed the limesurvey from gbresearch.net/research to research.gbresearch.net

Do you think it could be the problem? Yet, it seems it finds the file correctly.
Last Edit: 3 years 1 week ago by jorge_acevedo.

Please Log in to join the conversation.

More
3 years 1 week ago #109959 by tpartner
tpartner replied the topic: Autcomplete error "Uncaught typeError"
Try using an absolute path to the CSV.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
3 years 1 week ago #109973 by jorge_acevedo
jorge_acevedo replied the topic: Autcomplete error "Uncaught typeError"
Pardon my ignorance. But how do I do that?

Please Log in to join the conversation.

More
3 years 1 week ago - 3 years 1 week ago #109992 by jorge_acevedo
jorge_acevedo replied the topic: Autcomplete error "Uncaught typeError"
Tony,

Just wanted to let you know that I was able to fix it.

What I did:

I was using the jquery.csv.js version .5 that is posted on the limesurvey wiki
code.google.com/p/jquery-csv/source/brow...77f1d747bc860b943fe7

Apparently that's an old code.

I found in google a new version 0.71

code.google.com/p/jquery-csv/downloads/d...csv-0.71.js&can=2&q=

I replaced the old version for the new one and my autocomplete started working!!!


Thanks for your support.
Last Edit: 3 years 1 week ago by jorge_acevedo. Reason: changed mispelling

Please Log in to join the conversation.

More
3 years 1 week ago #109998 by tpartner
tpartner replied the topic: Autcomplete error "Uncaught typeError"
Thanks. I've updated the links on the Workaround page.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now