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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:47:35+00:00 2026-06-01T15:47:35+00:00

Updated Question: $(this).attr(EmployeeId, ‘A42345’); $.ajax({ type: POST, url: url, data: {EmployeeId: ‘ + id

  • 0

Updated Question:

$(this).attr("EmployeeId", 'A42345'); 

 $.ajax({
       type: "POST",
       url: url,
       data: "{EmployeeId: '" + id + "'}",
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       success: function (response) {
      var obj = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;

      var o = obj[$(this).attr("EmployeeId")]; //<<<<undefined

END UPDATE

i am trying to get EmployeeId withitn the DOM something like this:

var o = obj[$(this).attr("EmployeeId")];

but getting undefined

when i debug i see the following:

$(this)[0].data

     data    "{EmployeeId: 'A42345'}"     

here is my source code:

$.ajax({
           type: "POST",
           url: url,
           data: "{EmployeeId: '" + id + "'}",
           contentType: "application/json; charset=utf-8",
           dataType: "json",
      success: function (response) {
                  var obj = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;

                  var o = obj[$(this).attr("EmployeeId")]; //<<<<undefined
  • 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-01T15:47:36+00:00Added an answer on June 1, 2026 at 3:47 pm

    this is referring to your function in the example you gave. Therefore your selector isn’t matching anything.

    I’m guessing you are calling an ajax function from within a click handler or some other type of event handler.

    Assign $(this) to a variable in the first function and reference that variable in your success callback.

    $(el).click(function() {
        var $this = $(this);
        $.ajax({
           type: "POST",
           url: url,
           data: "{EmployeeId: '" + id + "'}",
           contentType: "application/json; charset=utf-8",
           dataType: "json",
           success: function (response) {
                  var obj = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
    
                  var o = obj[$this.attr("EmployeeId")]; //<<<<undefined
    // rest of code...
    

    Posting more of your code would help though..

    You may also be trying to access the data you were passing in.. in which case, parse it to json, or don’t pass it in as a string in the first place.. .attr won’t work on $(this) though, as this is referring to the function..

    $(this)[0].data is the function’s data. Which doesn’t have attributes, it’s not a DOM element.

    You are using some mismatched functionality, it’s hard for me to figure out exactly what your intent was.. You said you are trying to get it from the DOM, but you are showing the data of the function, those are two entirely different things.

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

Sidebar

Related Questions

I little while back I posted this question . I have updated that question
N.B THIS QUESTION HAS BEEN UPDATED, READ FURTHER DOWN Hi, I want to create
Sorry for the double post, I will update this question if I can't get
Just when I was about to post this question, I came up with an
NOTE: Updated and rewritten This question has been redone and updated. Please pardon outdated
UPDATED QUESTION I've updated this to be a little more succinct..: In this fiddle:
UPDATE: This question is out of date, but left for informational purposes. Original Question
Update: This question was an epic failure, but here's the working solution. It's based
Update: This question is a duplicate of Are there any programming languages targeting PHP,
UPDATE (spoiler): This question is answered (see David Carlisle answere below) and it looks

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.