Forums

Autocompleter can't retrieve results

Austre 13 Jan, 2015
The Autocompleter at CFV5.0.2 works fine or have some bug?

I make a simple example and it says "Loading Failed..."

[attachment=0]joomla01.JPG[/attachment]

[attachment=1]joomla02.JPG[/attachment]

return json_encode(array("Option1","Option2","Option3"));
GreyHead 14 Jan, 2015
Hi Austre,

I haven't used this action recently. If you look in your web browser developer tools you should be able to see what is being returned and use that info to debug. In Chrome it shows up on the Network tab I think.

Bob
Austre 14 Jan, 2015
Hi,

See images below!

[attachment=0]joomla03.JPG[/attachment]
[attachment=1]joomla04.JPG[/attachment]
GreyHead 14 Jan, 2015
Hi Austre,

The bottom image is close but it shows what is being sent *to* the server. Please check the Response and/or Preview tabs to see what is being sent back *from* the server.

Bob
Austre 14 Jan, 2015
I forget to say before, tab Preview and Response are empty.

"Failed to load response data"
GreyHead 14 Jan, 2015
Hi Austre,

OK - I spotted something else. You have an Authenticator action in the reProjecto event. I think that will always fail as this is a direct Ajax call from the browser so has no connection with the current user. Please try putting the Custom Code action directly in the parent event without the Authenticator.

Bob
Austre 14 Jan, 2015
Bob,

Same behavior.
GreyHead 16 Jan, 2015
Hi Austre,

Just checking - you do have <?php ?> tags in the Custom Code action?

Bob
Austre 16 Jan, 2015
Morning Bob,

My Custom Code have <?php ?> tags, looks like:

<?php
return json_encode(array("Option1","Option2","Option3"));
?>
GreyHead 16 Jan, 2015
Hi Austre,

That's how it should be - just checking all the possibilities. By all means email or PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
Austre 16 Jan, 2015
I got something diferent now.

I created a test form with this configuration:

[attachment=0]joomla05.JPG[/attachment]
[attachment=1]joomla06.JPG[/attachment]
[attachment=2]joomla07.JPG[/attachment]

<?php
$search = JRequest::getString('natureza', '', 'get');
$return = "";

if($search!="" && strlen($search)>2){
	$lstNatureza = array();
	$sql = "select CODTB1FAT as id, DESCRICAO as value from TTB1 where LEN(CODTB1FAT) = 8 and INATIVO = 0 and TTB1.DESCRICAO like '%".$search."%'";
	$conn = mssql_connect("myServer", "myUser", "myPass");
	$bco = mssql_select_db("myDB", $conn);
	$result = mssql_query($sql,$conn);
	
	while($row=mssql_fetch_array($result,MSSQL_ASSOC)){
		$row["value"] = utf8_encode($row["value"]);
		$lstNatureza[] = $row;
	}
	
	$return = json_encode($lstNatureza);
}

//return json_encode(array("Option1","Option2","Option3"));
echo $return;
?>


With this new cenario, i have the situation on browser. No more Loading Failed, but field keep spinning and no values appears:

[attachment=3]joomla08.JPG[/attachment]
[attachment=4]joomla09.JPG[/attachment]
[attachment=5]joomla10.JPG[/attachment]
Austre 16 Jan, 2015
I'm looking the Demo Autocomplete and got something...
Making some tests...
😲
Austre 16 Jan, 2015
Finally it works.

Now i'm asking myself why visual style got diferent:

[attachment=0]joomla11.JPG[/attachment]
[attachment=1]joomla12.JPG[/attachment]
GreyHead 16 Jan, 2015
Hi Austre,

Good to see that you got this working. The styling looks as though different CSS is being applied. You can check with your browser Web Developer tools.

Bob
Austre 16 Jan, 2015
Yeah,

I'm trying to identify that, but no success yet.
Still working on it.
😲
Austre 16 Jan, 2015
I got it.

When Autocomplete comes before HTML (Render Form), that situation with visual style occurs, but when it comes after, no problems.

Anyway, i'm in doubts cause at Demo Autocompleter, the Autocompleter comes before HTML (Render Form) and we have no problems, neither with another configurations (before/after HTML (Render Form), before/after Load CSS...)

I'll post my complete code and images later here to help someone else.
This topic is locked and no more replies can be posted.