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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:45:09+00:00 2026-06-09T01:45:09+00:00

Thanks for checking this out: What im doing is reading multiple values like name

  • 0

Thanks for checking this out:

What im doing is reading multiple values like name and class to determine the being clicked, then sending it as a paremeter to a PHP on my server so i can switch its class and name value.

This works great and switches the class the first time I click it, but the second time I click on the element, it does not work anymore. Looking at chrome’s console, i can see the POST result being successful, but the $.post callback function is not being run anymore.

$('a').click(function() {

            if($(this).attr("name")=="Config"){
                return;
            }
            else if ($(this).attr("name")=="Return"){
                return;
            }
            else if ($(this).attr("name")=="Temperatura"){
                return;
            }

            else{



            var parameters = {};                            
                parameters.devicename   =   $(this).attr("name").split('_')[0];
                parameters.devicevalue  =   $(this).attr("name").split('_')[1];
                parameters.devicestate  =   parseInt($(this).html());

                alert (parameters.devicestate);

                var selector;

                if ($(this).hasClass("Luz_On") || $(this).hasClass("Luz_Off")){
                selector = "Luz";   
                $(this).attr('id','ajaxelement');
                alert("entro");
                alert($(this).attr('name'));
                alert(selector);
                alert($(this).attr('id'))
                }
                else if ($(this).hasClass("Cortina_Up") || $(this).hasClass("Cortina_Down")){
                selector = "Cortina";           
                $(this).attr('id','ajaxelement');                   
                }
                else if ($(this).hasClass("Temperatura")){
                selector = "Temperatura";
                $(this).attr('id','ajaxelement');
                }
                else if ($(this).hasClass("Rewind")){
                selector = "Rewind";
                $(this).attr('id','ajaxelement');
                }
                else if ($(this).hasClass("Play")){
                selector = "Play";
                $(this).attr('id','ajaxelement');
                }
                else if ($(this).hasClass("Pause")){
                selector = "Pause";
                $(this).attr('id','ajaxelement');
                }
                else if ($(this).hasClass("Forward")){
                selector = "Forward";
                $(this).attr('id','ajaxelement');
                }

            $.post(

            "http://localhost/AplicacionWeb/test.php", 

            parameters,

            function(data){

            if (data.valid=='true')
            {

                switch(selector)
                {
                    case "Luz":

                        alert("case");

                        if ($('#ajaxelement').attr('name') == "Luz_On"){

                        alert("caseif1");
                        $('#ajaxelement').removeClass("Luz_On").addClass("Luz_Off");
                        $('#ajaxelement').attr('name','Luz_Off');
                        $('#ajaxelement').removeAttr('id');

                        }
                        if ($('#ajaxelement').attr('name') == "Luz_Off"){

                        alert("caseif2");
                        $('#ajaxelement').removeClass("Luz_Off").addClass("Luz_On");
                        $('#ajaxelement').attr('name','Luz_On');
                        $('#ajaxelement').removeAttr('id');

                        }




                    break;

                    case "Cortina":

                    break;

                    case "Temperatura":

                    break;

                    case "Rewind":

                    break;

                    case "Play":

                    break;

                    case "Pause":

                    break;

                    case "Forward":

                    break;

                    default:
                        alert("C'est la vie");
                }




            }//data.valid

            }, 

            "json"

            );

            }



        });  // end click
  • 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-09T01:45:11+00:00Added an answer on June 9, 2026 at 1:45 am

    You configured your post requests to expect the server, http://localhost/AplicacionWeb/test.php, to return valid JSON. If you verified that the request returned successfully, then check if the data conform to the specified dataType. jQuery ajax requests will not run the success/done callback if the response data is invalid.

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

Sidebar

Related Questions

Thanks for checking out this Question. I think I've just about scratched through my
Thanks for checking this out people. I'm learning PHP from PHP for Absolute Beginners
Thanks for reading this. I have no idea why this is throwing a NullReferenceException
So I've spent some time checking out CocoaDev, reading the Cocoa docs on NSMenuItems,
Greetings everyone and thank you for checking out my post. I am trying to
Thanks for stopping by. this static analyser warning is annoying me here is my
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
I'm working on a graphical application which looks something like this: while (Simulator.simulating) {
Okay I know there is lots of info out there on this and I
So here's what I'm doing -- I have a ruby script that prints out

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.