Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8778107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:26:44+00:00 2026-06-13T19:26:44+00:00

i´m using ajax to use a keyword search on a mysql database, and when

  • 0

i´m using ajax to use a keyword search on a mysql database, and when results are coming i want to show options as href with an onclick function, the search works fine, but when i click on any option i get a reference error on my firebug, this is the code:
index.php

 <html>

<body>
    <style>
        #displayDiv {
            background-color: #ffeeaa;
            width: 200;
        }
    </style>
    <script type="text/javascript">
        function aca(esto) {
            var esta = esto;
            alert(esta);
        }
    </script>
    <script type="text/javascript">
        function ajaxFunction(str) {
            var httpxml;
            try {
                // Firefox, Opera 8.0+, Safari
                httpxml = new XMLHttpRequest();
            } catch (e) {
                // Internet Explorer
                try {
                    httpxml = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                        httpxml = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) {
                        alert("Your browser does not support AJAX!");
                        return false;
                    }
                }
            }

            function stateChanged() {
                if (httpxml.readyState == 4) {
                    document.getElementById("displayDiv").innerHTML = httpxml.responseText;

                }
            }
            var url = "search.php";
            url = url + "?txt=" + str;
            url = url + "&sid=" + Math.random();
            httpxml.onreadystatechange = stateChanged;
            httpxml.open("GET", url, true);
            httpxml.send(null);
        }
    </script>
    </head>
    
    <body>
        <form name="myForm">
            <input type="text" onkeyup="ajaxFunction(this.value);" name="username"
            />
            <div id="displayDiv"></div>
        </form>
    </body>

And this is the search.php

<?php
include ("dbinfo.php");
$in = $_GET['txt'];
$msg = "";
if (strlen($in) > 0 and strlen($in) < 20) {
    $t = mysql_query("select RubroId, RubroDisp from rubros where KeyWords like '$in%'");
    while ($nt = mysql_fetch_array($t)) {
        $valor = $nt[RubroDisp];
        $valorCodificado = str_replace(" ", "_", $valor);
        echo "<a href='#' onclick='aca($valorCodificado);'>$valor</a><br />";
        
                                        }
                                          }
?>

You can see the working page at this url

Can you please tell me how to solve it? or what i am doing wrong?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:26:46+00:00Added an answer on June 13, 2026 at 7:26 pm

    aca($valorCodificado); will generate JavaScript that calls a function with a variable (that probably doesn’t exist) for the argument. It looks like you want a string there. Strings require quotes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ajax to get some data then based on the data use html()
I am using dojo forms and submitting using AJAX. I use 2 methods of
I'm using $.ajax() to send a post call to the server. If I use
I'm using jquery mobile in my express project. How could I use Ajax for
Hi I am trying to run an ajax query using jquery. If I use
I am using HMVC codeigniter. I am trying to use jquery ajax first time.
I want to dynamically load JS file using AJAX and execute it. I am
I want to paginate comments section of my wordpress blog using ajax. How would
I have an ASP.Net MVC page where I want to use AJAX to update
I build a custom AuthenticationSuccessHandler so users can login using Ajax aswell use a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.