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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:52:29+00:00 2026-05-29T03:52:29+00:00

i know how to post data using javascript but im trying to work out

  • 0

i know how to post data using javascript but im trying to work out how i can retrieve the last inserted row in a mysql table.

So i can use it in my success result.

Below is what i have so far but all it does is create the entry , i really want to direct the user to a page where they can now edit their new entry without having them click a button to go there first.

The code below has not got the part i really need, i just put it up so you can see my structure of what i am doing.

$("#CREATEDOCUMENT").click(function() {

var txt = $.ajax({
url: 'create_doc_entry.php',
async: true, 
type:'POST',
data:({
usr_id:$('input#usr_id').val(),
}) 

}).success;

$('.pleasewait').fadeIn('slow');    

setTimeout(function(){window.location="index.php?v=editdoc&id="+id;}, 2000);

}); 

As you can see from the above in the window.location url i have +id

I would really love that +id to be my last inserted id which i grab from the create_doc_entry.php file if you know what i mean.

Thanks in advance
John

  • 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-29T03:52:30+00:00Added an answer on May 29, 2026 at 3:52 am

    First you will need to modify create_doc_entry.php so that it prints the last inserted ID after the INSERT.

    Then you probably should add the success setting in your ajax request, like this:

    var txt = $.ajax({
        url: 'create_doc_entry.php',
        async: true, 
        type:'POST',
        data:({
            usr_id:$('input#usr_id').val(),
        }),
        success: function( data ) { alert(data); }
    });
    

    So you can parse or do whatever you want with data in the success function.

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

Sidebar

Related Questions

If possible, how can I get (and post) data from a mysql database using
I know I'm messing up the syntax somewhere but I can't figure out where.
I am wondering why: $.post(remote.php, {'f':a_searchtype, 'partial':value}, function(data){ $(#result).html(data); }); worksfine. but using a
Is there a way to obtain the post data itself? I know spring handles
I know you should use POST whenever data will be modified on a public
I know there is this post , but I still want to know more
I cant post the code (proprietary issues) but does anyone know what types of
Does anyone know how to initiate a POST request in a Grails applications using
Does anyone know how to insert a new post into Wordpress using sql?
I am using JavaScript and trying to make a skew effect on a div.

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.