I had a similar problem and here is how I finally resolved it (i.e., no more $cluetip
undefined error msg).
First, here is my scenario which may be similar to yours. On the page, I have a
<div id="sel_area"></div>
It is empty and the idea is to employ jquery/ajax to dynamically generate the desired <select><option>...</option>...</select>
HTML code to insert into the #sel_area
above like so
$('#sel_area').html(data);
where data is the generated HTML select
tag.
However, I think my problem is because I was not retuning the dynamically generated data result in JSON or in XML format and then processing it accordingly. Instead, I was lazily returning the result as-is as ordinary text/html. When I kept getting the $cluetip
is undefined error no matter what I tried, I decided to use alert(data)
to see was was being returned. Alas, there I saw with my own eyes that data was not just only what I had echoed but it had the entire html page appended to it! The solution was then clear to me. Without giving in to returning data in XML or JSON protocol, I made the following minor changes to solve the problem:
The change at the remote script that generates the <select>
tag. The last last was
echo "$select_tag";
I changed this to
echo "$select_tag~";
That is, I appended a trailing ~ (tilde) to serve as a separator between my select_tag
string output and the HTML page that I now knew would be appended whether I liked it or not.
The change in the jQuery/AJAX method.
I replaced the line
$('#sel_area').html(data);
with the following lines:
data_list = data.split('~');
$('#sel_area').html(data_list[0]);
There you have it. That does the trick. The split method enabled me to detach my desired select_tag
from data easily because I had wisely inserted ~ (tilde) to serve as my field separator which I knew was neither part of the select_tag
result nor the HTML page to be appended by the system. Hope this helps.