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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:25:15+00:00 2026-06-16T07:25:15+00:00

flagUpdateCustomer = 0; $(input#checknames).click(function () { $.ajax({ url: ‘php.scripts/checknames.php’, data: { firstname: $(input#firstname).val(), lastname:

  • 0
flagUpdateCustomer = 0;
$("input#checknames").click(function () {
    $.ajax({
        url: 'php.scripts/checknames.php',
        data: { firstname: $("input#firstname").val(),
            lastname: $("input#lastname").val(),
            address1: $("input#address1").val(),
            address2: $("input#address2").val(),
            city: $("input#city").val(),
            state: $("input#state").val(),
            zip: $("input#zip").val(),
            phone: $("input#phone").val(),
            email: $("input#email").val(),
            cell: $("input#cell").val()
        },
        type: 'post',
        async: false,
        success: function (output) {
            var obj = $.parseJSON(output);
            $("#existcustomers").empty();
            for (var iCnt = 0; iCnt < obj.length; iCnt++) {
                if (obj[iCnt].firstname == null) { obj[iCnt].firstname = ""; }
                if (obj[iCnt].lastname == null) { obj[iCnt].lastname = ""; }
                if (obj[iCnt].address1 == null) { obj[iCnt].address1 = ""; }
                if (obj[iCnt].address2 == null) { obj[iCnt].address2 = ""; }
                if (obj[iCnt].city == null) { obj[iCnt].city = ""; }
                if (obj[iCnt].state == null) { obj[iCnt].state = ""; }
                if (obj[iCnt].zip == null) { obj[iCnt].zip = ""; }
                if (obj[iCnt].phone == null) { obj[iCnt].phone = ""; }
                if (obj[iCnt].email == null) { obj[iCnt].email = ""; }
                if (obj[iCnt].cell == null) { obj[iCnt].cell = ""; }

                var newRow = $("<tr><td>" + obj[iCnt].firstname + "</td><td>" + obj[iCnt].lastname + "</td><td>" + obj[iCnt].address1 + "</td><td>" + obj[iCnt].address2 + "</td><td>" + obj[iCnt].city + "</td><td>" + obj[iCnt].state + "</td><td>" + obj[iCnt].zip + "</td><td>" + obj[iCnt].phone + "</td><td>" + obj[iCnt].email + "</td><td>" + obj[iCnt].cell + "</td></tr>").data('id',obj[iCnt].id);
                $("#existcustomers").append(newRow);
            }


            $("#existcustomers tr").hover(function () { $(this).addClass("highlight"); }, function () { $(this).removeClass("highlight"); });

            $("#existcustomers tr").click(function () {


                $("#form-main").data('id', $(this).data('id'));

                $("input#firstname").val($(this).children(":eq(0)").text());
                $("input#lastname").val($(this).children(":eq(1)").text());
                $("input#address1").val($(this).children(":eq(2)").text());
                $("input#address2").val($(this).children(":eq(3)").text());
                $("input#city").val($(this).children(":eq(4)").text());
                $("input#state").val($(this).children(":eq(5)").text());
                $("input#zip").val($(this).children(":eq(6)").text());
                $("input#phone").val($(this).children(":eq(7)").text());
                $("input#email").val($(this).children(":eq(8)").text());
                $("input#cell").val($(this).children(":eq(9)").text());

                $("input#firstname").attr('disabled', 'disabled');
                $("input#lastname").attr('disabled', 'disabled');
                $("input#address1").attr('disabled', 'disabled');
                $("input#address2").attr('disabled', 'disabled');
                $("input#city").attr('disabled', 'disabled');
                $("input#state").attr('disabled', 'disabled');
                $("input#zip").attr('disabled', 'disabled');
                $("input#phone").attr('disabled', 'disabled');
                $("input#email").attr('disabled', 'disabled');
                $("input#cell").attr('disabled', 'disabled');

                $("#form-main").data('firstname', $("input#firstname").val());
                $("#form-main").data('lastname', $("input#lastname").val());
                $("#form-main").data('address1', $("input#address1").val());
                $("#form-main").data('address2', $("input#address2").val());
                $("#form-main").data('city', $("input#city").val());
                $("#form-main").data('state', $("input#state").val());
                $("#form-main").data('zip', $("input#zip").val());
                $("#form-main").data('phone', $("input#phone").val());
                $("#form-main").data('email', $("input#email").val());
                $("#form-main").data('cell', $("input#cell").val());

                //I am trying to determine how to call .ajax again to set my $_SESSION in PHP
                //A recursive call to .ajax does not seem to be a good option here
                //I was hoping to see somthing about an onchange or onupdate event in the jQuery docs
                //for .data() however I had no such luck. Perhaps could I use just the onchange()
                //event of #form-main? Essentially once the data is set in #form-main I have to call
                //.ajax again for add.customer.session.php. I am confused right now.

                //????????????????

                //
                //

                $('#form-main').css('background-color', 'green');
            });
        }


    });  


});

I have a call to .ajax() and inside of that call there is set a $("#existcustomers tr").click() and inside of that click the most logical way for to handle things would be another call to .ajax() inside of the first however I am looking for another option. I am wondering at this point if there is some easy way to hook an event to #form-main and run some code after .data() sets the data to #form-main. As always thank you all in advance for any suggestions or commentary related to this code!

  • 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-16T07:25:16+00:00Added an answer on June 16, 2026 at 7:25 am

    I don’t think you have a recursive problem here. You just have chained ajax calls. This would really only be a problem if it could loop around around and call the original action again.

    Since know that your first ajax call will make another ajax call, you could make both at the same time as an asynchronous call or if you have control over the server API, allow for both types of data to set/requested in one call.

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

Sidebar

Related Questions

No related questions found

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.