Hi, I have a perl page where I am using the jQuery autocompleter. I am calling another perl script which generates json output. The page works but not all the time. Here are my scripts. index.pl
<script type="text/javascript" src="/xyz/jquery/js/jquery-1.7.1.min +.js"></script> <script type="text/javascript" src="/xyz/jquery/js/jquery-ui-1.8.17 +.custom.min.js"></script> <script type="text/javascript"> \$(document).ready(function(){ var byname = { source: "searchbyname.pl", select: function(event, ui){ \$("#cn").val(ui.item.cn); \$("#xyzid").val(ui.item.xyzid); \$("#xyzuid").val(ui.item.xyzuid); \$("#mail").val(ui.item.mail); }, minLength:2 }; \$("#cn").autocomplete(byname); } </script> <input type="text" name="cn" id="cn" value="$cn" size="40" maxlength=" +128" onClick="clearForm();" />
searchbyname.pl
my @query_output; # LOOP THROUGH RESULTS while ( my $row = $sth->fetchrow_hashref ){ push @query_output, $row; } my $json = JSON::to_json(\@query_output); &log("I am in search by name page looking for $inpstr returning $json + "); print $json;
When I check the web console in firefox, the output is as follows:
[17:08:56.206] GET http://server.xyz.com/xyz/cgi-bin/searchbyname.pl?t +erm=batt [HTTP/1.1 200 OK 375ms] [17:08:56.579] syntax error @ http://server.xyz.com/xyz/cgi-bin/search +byname.pl?term=batt:1 [17:08:57.830] GET http://server.xyz.com/xyz/cgi-bin/searchbyname.pl?t +erm=batte [undefined 375ms]
I start the search with string batt, The first line where is shows the status as 200 OK, the auto completer shows up with the results, even if it is complaining in the next line about the syntax of the json. then I press next letter e and the autocompleter does not come up. the firefox console shows the request/response in the third line and it says undefined. I am printing the json passed to index.pl in the log and the output is there and I validated the output online and it comes back as valid json. I have no idea, what am I doing wrong. please help. Thanks, Sushma

In reply to perl jquery script returns http status undefined sometimes by sushmas.sharma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.