When you return "response" in your AJAX, it's not "1". It's
"<html><head>...</html>". jQuery doesn't automatically go through your
HTML and look in the body to find the "1".
In your server-side code, you don't return the whole HTML page. You
just return the String "1" (without the quotes). Such that if you load
up check10.asp, and view its source, all you see is a "1". That's it.

In your AJAX response conditional check, you want to do
if (response == "1")
(with the double-quotes)
Otherwise, you're checking for an integer. What's returned is a String
type.

On Sep 28, 10:31 am, factoringcompare <firstfacto...@googlemail.com>
wrote:
> OK, thank you for taking the time out to look at this issue for me. Ok
> this is the code client side page:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1" />
> <title>Ajax Username Checker - Using JQuery</title>
> <style>
> #username{
>         padding:3px;
>         font-size:18px;
>         border:3px #CCC solid;
>
> }
>
> #tick{display:none}
> #cross{display:none}
> </style>
> <script type="text/javascript" src="Sitefiles-N/
> jquery.formwizard-0.9.8/./jquery-1.3.2.js"></script>
>
> <script>
> $(document).ready(function(){
> $('#username').keyup(username_check);
>
> });
>
> function username_check(){
>
> var username = $('#username').val();
>
> if(username == "" || username.length < 4){
> $('#username').css('border', '3px #CCC solid');
> $('#tick').hide();
>
> }else{
>
> jQuery.ajax({
>    type: "POST",
>    url: "check10.asp",
>    data: 'username='+ username,
>    cache: false,
>    success: function(response){
> if(response == 1){
>         $('#username').css('border', '3px #C33 solid');
>         $('#tick').hide();
>         $('#cross').fadeIn();
>         }else{
>         $('#username').css('border', '3px #090 solid');
>         $('#cross').hide();
>         $('#tick').fadeIn();
>              }
>
> }
> });
> }
> }
>
> </script>
>
> </style>
> </head>
> <body>
>
> Username: <input name="username" id="username" type="text" />
> <img id="tick" src="Sitefiles-N/jquery.formwizard-0.9.8/tick.png"
> width="16" height="16"/>
> <img id="cross" src="Sitefiles-N/jquery.formwizard-0.9.8/cross.png"
> width="16" height="16"/>
>
> </body>
> </html>
>
> The file is posted here:http://www.factoringcompare.com/test1.asp
>
> The server side code:http://www.factoringcompare.com/check10.asp
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> </head>
>
> <body>
> 1
> </body>
> </html>
>
> If I am following the code correctly by putting a "1" on  check10.asp
> the script should return that the username is taken. Which it is not
>
> On Sep 28, 9:05 pm, MorningZ <morni...@gmail.com> wrote:
>
> > Why do you have a page with a php extension?
>
> > As for helping further, it would be a huge help if you post some non-
> > working code...  you could have a bad selector, bad syntax, who
> > knows...
>
> > On Sep 28, 3:15 pm, factoringcompare <firstfacto...@googlemail.com>
> > wrote:
>
> > > I can’t get it to work. Something strange is happening.
>
> > > To manually check if the client side code is working I put “1” in the
> > > server side page with a .php extension and sure enough I can get the
> > > code to work. If I do the same with a .asppage it has no effect. Any
> > > thoughts what’s going on?
>
> > > On Sep 28, 7:36 pm, MorningZ <morni...@gmail.com> wrote:
>
> > > > "This is the php code I can't mimic: "
>
> > > > Really?   the code is super simple:
>
> > > > - Open connection to the database
> > > > - Take the posted value of "username", trim it, and make lower case
> > > > - Clean up the string to help prevent SQL injection attack
> > > > - Take that username and check against the database
> > > > - echo (Response.Write) the number of rows found
> > > > - Close the database connection
>
> > > > On Sep 28, 1:26 pm, factoringcompare <firstfacto...@googlemail.com>
> > > > wrote:
>
> > > > > OK, I am trying to get this example to work 
> > > > > :http://papermashup.com/jquery-php-mysql-username-availability-checker/
>
> > > > > This is the php code I can't mimic:
>
> > > > > <?php
> > > > > include("dbConnector.php");
> > > > > $connector = new DbConnector();
>
> > > > > $username = trim(strtolower($_POST['username']));
> > > > > $username = mysql_escape_string($username);
>
> > > > > $query = "SELECT username FROM usernameCheck WHERE username =
> > > > > '$username' LIMIT 1";
> > > > > $result = $connector->query($query);
> > > > > $num = mysql_num_rows($result);
>
> > > > > echo $num;
> > > > > mysql_close();
>
> > > > > On Sep 28, 2:16 pm, MorningZ <morni...@gmail.com> wrote:
>
> > > > > > Take an example page in php that you want to mimic, and simply have
> > > > > >aspsend back to the browser the same information
>
> > > > > > On Sep 28, 3:58 am, factoringcompare <firstfacto...@googlemail.com>
> > > > > > wrote:
>
> > > > > > > Hi,
>
> > > > > > > Reasonably new to web building. I am now just updating my site 
> > > > > > > with
> > > > > > > jQuery (first time user).
>
> > > > > > > I would like to implement an Ajax username checker on a new client
> > > > > > > registration form. All the tutorials and examples I can find use
> > > > > > > jQuery and php. Unfortunately, I have taught myself Access 
> > > > > > > andASPand
> > > > > > > have no knowledge of php. At this stage I want to stick withASPand
> > > > > > > Access and look to upgrade the DB as another project.
>
> > > > > > > Can any body point me in the right direction to obtain some code.
>
> > > > > > > Kind regards.- Hide quoted text -
>
> > > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
>
>

Reply via email to