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 6101385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:29:39+00:00 2026-05-23T13:29:39+00:00

im trying to implement the classic username availability checker with jquery and ajax. here’s

  • 0

im trying to implement the classic username availability checker with jquery and ajax. here’s my approach:

jquery, on client side:

$("#usrnameTBox").keyup(function(){
    if ($(this).val().length > 2) {
    $.ajax({
        type: 'POST',
        url: 'ajax/ajaxPerfil.php',
        data: { function : "askForUsr", usrname: $(this).val() },
        dataType: 'json',
        success: function(data) {
            alert(data);
            if(data.exists) {
                $(".usrSt").attr('style', '')
                    .attr('style', "color:red;")
                    .html('YA ESTÁ EN USO');
            } else {
                $(".usrSt").attr('style', '')
                    .attr('style', "color:green;")
                    .html('Disponible!!!');
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            alert("Error!!! =/");
        }
    });
    } else {
        $(".usrSt").attr('style', '')
            .attr('style', "display:none;")
            .html('');
    }
});

php, on server side:

<?php
    require_once("../src/ajax/ajaxPerfilController.php");
?>

ajaxPerfilController.php:

<?php
$srcFolder = "../src/";
$classes = array("mappers/Perfil.php",
                 "fachadas/PerfilFachada.php"
                 );
foreach ($classes as $class)
  require_once($srcFolder.$class);

function getByAttr($attr, $value) {
  if (strcmp($attr,"usrname") == 0) {
    $fachada = PerfilFachada::singleton();
    return $fachada->exists($value);
  }
  return NULL;
}

if (isset($_POST["function"])) {
  if (strcmp($_POST["function"],"askForUsr") == 0) {
    if (isset($_POST["usrname"])) {
      if (getByAttr("usrname",$_POST["usrname"])) {
        $return["exists"] = True;
        echo json_encode($return);
      } else {
        $return["exists"] = False;
        echo json_encode($return);
      }
    }
  }
}
?>

The thing is, it keeps telling me server error 500!!! the require routes are ok since i’ve harcoded the request and tried it on the console… So, i dont know what else to do, i’ve tried with dataType ‘html’, ‘text’, ‘json’ in the ajax call, but got the same result. I gess its just a simple thing, but i just dont know what to do…

just in case, im using google-chorme

thanks for your help!!! =)

  • 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-05-23T13:29:39+00:00Added an answer on May 23, 2026 at 1:29 pm

    There are some reasons because you can get a 500 Error, including execution/compiling time errors.

    The only error I see is that you’re not declaring your $return var (well, php doesn’t need declaration, but needs an array when you access with brackets), i’d add $return = array(); before using it.

    BUT, You should debug your code to find the error. Depending on your tools, the best would be to set a breakpoint and start debugging. If you can’t do this for any way, my advise is to use Firebug for Firefox and see what error are you receiving (in the Net panel, Response section).

    Hope this helps. Cheers

    PS: If you have logs in your server, you could find the error there.

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

Sidebar

Related Questions

I'm trying to implement a REST interface under IIS5.1/ASP-classic (XP-Pro development box). So far,
I'm developing an asp.net (classic) application trying to implement the MVP pattern using this
I'm trying to find a good way to implement MVP in classic Winforms, and
Trying to implement the example from here. Facebook Share passes along the URL of
I am trying to implement a classic Windows Explorer kind of Application, CpliterWnd has
All I am currently trying implement something along the lines of dim l_stuff as
trying to implement a dialog-box style behaviour using a separate div section with all
Trying to implement a rating system of users and postings. What is the best
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
Am trying to implement a generic way for reading sections from a config file.

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.