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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:51:01+00:00 2026-05-27T10:51:01+00:00

No this is not another question about how to use AJAX. Why does this

  • 0

No this is not another question about how to use AJAX.

Why does this not work for me ?

What the code should do:

  1. When a button is clicked, it should send a Title and a User id to a PHP file, which should insert that in the database.

  2. Then it should make a .each on all elements inside a div, and send each of them to a PHP file, which should insert them to the database.

  3. and finally it should redirect.

I get the first alert with “first” but i don’t get the one with “second” and nothing is inserted in the database.

My previous code worked fine with inserting, and it does the same, just not as advanced and without the redirect function

my code:

$('#tabCreateButton').click(function () {
    alert("first"); //checking for click

    $.ajax({
        type: "POST", url: "/page/newtab.php", data: "action=newtitle&tabname=" + tabname + "&bid=" + brugerid,
        complete: function (data) {
            alert("second"); //checking for response
            var tabid = $(data.responseText);

            var XHRs = [];

            $('#tabCurrentFriends > .dragFriend').each(function () {
                var friendid = $(this).data('rowid');
                XHRs.push($.ajax({
                    type: "POST", url: "page/newtab.php", data: "action=newtab&tabid=" + tabid + "&bid=" + brugerid + "&fid=" + friendid,
                    complete: function (data) {
                    }
                }));
            });

            $.when(XHRs).then(function () {
                alert("third"); //should redirect here.
            });
        }
    });
});
  • 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-27T10:51:01+00:00Added an answer on May 27, 2026 at 10:51 am

    You either have an XHR error or a Javascript error you are not seeing.

    You can check for these errors using Chrome’s built in debugger (F12 –> Network –> XHR) or Firebug.

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

Sidebar

Related Questions

This is not another question about 'How Can I Sort Dynamically (based on an
I have (another) question about indexing. I use the following code: CREATE TABLE [dbo].[PnrDetails1](
I asked this morning a question about a jQuery code that's not working (which
I have this conceptual question about ajax that I'm not sure if I understand.
The current top-voted to this question states: Another one that's not so much a
[Note: There is another thread about this problem but it did not answer the
Why does this not work? Do I not understand delegate covariance correctly? public delegate
I've done this before with inputs, why on earth does this not work? http://euroworker.no/user/checkout
I had another question about this issue, but I didn't ask properly, so here
Following this question I decided to use ffmpeg to crop MP3s. On another question

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.