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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:40:51+00:00 2026-05-23T19:40:51+00:00

Jquery Ajax Call inserts new record on DB. File been called (php) needs to

  • 0

Jquery Ajax Call inserts new record on DB. File been called (php) needs to return two values, the contents of the insert and it’s id.

How should I send back these values (array, xml, echo) on php?

How will I separate these in the Jquery Ajax success (data)?

Currently the processing php file returns only one string being the inserted content with which I then update view. Need to return the record id so i can wire the element.

Please advice if this needs more clarification. Thank You

JQUERY

$.ajax({
                    type:'post',
                    url: 'posts_in.php',
                    data: $("#postentry").serialize(),
                    success:function(data){
                        var id='posts';
                        //split returned data here
                        $('<div></div>').attr('id',id).addClass('boxee').html(data).prependTo('#boxer');
                        $('#tittle_ent').val('').focus();
                    }

PHP

echo $value1,$value2;

print_r($arrayhere);

XML ?

  • 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-23T19:40:52+00:00Added an answer on May 23, 2026 at 7:40 pm

    Return a JSON string encoded with json_encode().

    $php_array_result = array(1,2,3,4,5,6);
    
    // Send the correct MIME header and echo out the JSON string
    header("Content-type: application/json");
    echo json_encode($php_array_result);
    exit();
    

    In your jQuery ajax call, add the dataType: "json" property.

    $.ajax({
       type:'post',
       url: 'posts_in.php',
       dataType: "json",
       success: function(data) {
          console.dir(data);
       },
       // etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My index.php has a jquery ajax call that inserts getposts.php into my #content div.
I am calling a .txt file from a jquery ajax call. It has some
I'm calling a php function from my $.ajax call to add a new item
So I am trying to use jQuery to insert data from an ajax call.
I am making a jquery ajax call to an mvc controller. I want to
I have a jQuery AJAX call with type:'GET' like this: $.ajax({type:'GET',url:'/createUser',data:userId=12345&userName=test, success:function(data){ alert('successful'); }
Let's say I have the following jQuery AJAX call: $.ajax({ type: POST, url: MyUrl,
Is it possible to use a jQuery ajax call to perform Forms Authentication with
How would you access the cache from a jQuery ajax call? I'm using jquery
A situation I ran across this week: we have a jQuery Ajax call that

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.