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

  • SEARCH
  • Home
  • 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 8290613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:51:40+00:00 2026-06-08T12:51:40+00:00

Basically i am trying to create a AJAX script in Jquery. but the main

  • 0

Basically i am trying to create a AJAX script in Jquery.
but the main problem is that i want to define the variables like this

$(document).ready(function () {
    var u = $('#username');
    var s = $('#server');
    var p = $('#password');

    $('#server').keyup(function () {
         $.post("connect.php", { s: s.value, u: u.value , p: p.value },
             function(data) {
             $('#hol').html('checking connection...' + u.value + " " + p.value + " " + s.value + " " + data);
                             }
                 ); 
   });

});

But that somehow doesn’t work…. it seems rather odd that i have to define the variables with “this” instead of being able to assign them before hand.

the code that works is

$(document).ready(function () {

    $('#username').keyup(function () {
        var u = this;
            $('#password').keyup(function () {
            var p = this;
                   $('#server').keyup(function () {
                    var s = this;

                     $.post("connect.php", { s: s.value, u: u.value , p: p.value },
                     function(data) {
                        $('#hol').html('checking connection...' + u.value + " " + p.value + " " + s.value + " " + data);
                                         }); });
                 }); 
                  }); 
   });

so my question is basically “How do I make jquery catch the input in the text field and assign it to a variable? like in the first example??” or it doesnt have to be done in the long way?

  • 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-08T12:51:41+00:00Added an answer on June 8, 2026 at 12:51 pm

    You need to use .val() instead of .value:

    { s: s.val(), u: u.val() , p: p.val() }
    

    as s,u,and p are jQuery objects, not DOM Elements.

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

Sidebar

Related Questions

I am trying to create something in Perl that is basically like the Unix
I'm trying to use AJAX (not jQuery).... I basically have this going on. Content
im stuck with a problem im basically trying to create a function where I
I'm trying to create a function that searches up a WebControl's parent-child relationship (basically
I encountered a weird problem when trying to write a cross-browser script. Basically my
I'm trying to create my custom toolbox which imitates jQuery's design pattern. Basically, the
I'm basically trying to create a generic object in javascript that I can use
So, basically I have this select / drop down menu that I use AJAX
Basically, I referred to some sources, and found this: Yah, that's easy, just create
I'm trying to create a bookmarklet that will start off an AJAX call to

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.