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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:14:33+00:00 2026-05-12T17:14:33+00:00

I am trying to send a name:value pair to a php script using the

  • 0

I am trying to send a name:value pair to a php script using the $.post object in jQuery where both name and value are variables. I have sent the variables to the console in FF, so I know they are being set correctly, but when I view the headers being sent, only the value variable is being evaluated correctly, the name is being sent as a literal string of the variable name. Here is the function in its entirely:

$(document).ready(function() {
  $('#formS form fieldset > input').blur(function() {
    if($(this).val()=='' && $(this).prev().is('img')) {
     $(this).prev().remove();
     return;
    }

    if((($(this).is('#formS form fieldset > input[id*=mail]')) ||
    ($(this).is('#formS form fieldset > input[id*=sername]'))) &&
    ($(this).val()!="")) {
      var email_field = $(this);
      if(!$(this).prev().is('img')){
      $('<img src="" alt="" style="width: 16px; height: 16px;" />').insertBefore(this);
      }
      var type = ($(this).is('input[id*=sername]'))?'username':'email';
      var value = $(this).val();
      $.post('checkemail.php5', {type:value}, function(data) {
                if(data == "free") {
         email_field.prev().attr('src','/images/greentick.png').attr('alt','available');
        } else if(data == "taken") {
         email_field.prev().attr('src','/images/redcross.png').attr('alt','taken');
        } else {
          console.log('hmmm'+data);
        }
        });
        }
        });
});

So, the headers being sent are the literal string type, and whatever value evaluates to. Anybody have any ideas why?

  • 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-12T17:14:33+00:00Added an answer on May 12, 2026 at 5:14 pm

    Because the syntax {} takes a set of name:value where the names become the property on the object. This is a literal and cannot be a variable, as you see. Use this:

    var params = {};
    params[type] = value;
    

    and pass params instead of {type:value}

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

Sidebar

Related Questions

I am performing an HTTP POST of a name/value pair and then trying to
I'm currently trying to send a post to a php script, which seems to
am trying send an array to php file using $_POST ,still always getting an
what im trying to do is to send data in JSON using jquery to
I am trying to send a value from my test.php to my backgroundScript.php through
I'm trying to make a simple settings script, which basically send a setting name
I am trying to send data to a web server using a post, this
I'm trying to send some data via ajax with jquery var name = $(.name).attr(data-name);
Trying to send a complex type between two systems that have the same code
im trying to send rest api Users.getLoggedInUser i have all the secret session and

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.