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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:26:53+00:00 2026-05-28T01:26:53+00:00

this is probably something very simple to fix. Im posting to a php page

  • 0

this is probably something very simple to fix. Im posting to a php page that returns the ID of the new element created in the db- (posting via $.ajax)- i have logged the returned value.

The following code is the code i use to post

$.ajax({
               type: "POST",
               url: "<?=base_url()?>events/add_tag_js/",
               data: url,
               success: function(html){

                   $("#tag_list").append('<li><span id="" class="tag">'+formvalue+'<span class="remove_tag"><a class="remove_tag_link" href="#">x</a></span></span></li>');
                   $("#add_tag").val('');
                   console.log(html);
               },
               failure: function(){
                    $('.error').show();
                    $("#add_tag").val('');
               }

            });

The return value from the console.log is

{"error":false,"msg":"Tag added","id":44}

but when i do alert(html.id) i get undefined? do i need to parse the json returned to do this? or is my json incorrect?

  • 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-28T01:26:54+00:00Added an answer on May 28, 2026 at 1:26 am

    Maybe you didn’t set the proper content type on your server side script, so jQuery doesn’t know that this is JSON. So either set the content type to application/json on your server script or you could also indicate that you expect JSON in the request using the dataType parameter:

    ...
    type: "POST",
    url: "<?=base_url()?>events/add_tag_js/",
    data: url,    
    dataType: 'json', // indicate that you expect JSON from the server
    ...
    

    Although it is recommended to have your server side script set the proper content type.

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

Sidebar

Related Questions

This is probably something really simple, however I am quite new to PHP, and
I'm a bit new to make, so this is probably something really very simple,
This is probably something very obvious, but I have a new to Qt and
I'm sure this is something very simple that I'm screwing up, but here goes:
All, This question probably has a very simple answer - something I'm overlooking. But
I wonder if this is something very simple that I'm just missing, or if
This is probably a very simple question to answer. i am new to Rails
This is probably something very simple but I'm looking for the optimal way of
This is probably something very simple but I'm not getting the results I'm expecting.
This is probably something very simple, so forgive my blonde moment :) I have

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.