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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:54:12+00:00 2026-06-06T12:54:12+00:00

I am using this code to post some data $(‘.update_btn’).live(click,function() { var ID =

  • 0

I am using this code to post some data

$('.update_btn').live("click",function() 
{
var ID = $(this).attr("id");
var dataString = 'msg_id='+ ID;

$.ajax({
type: "POST",
 url: "get-data.php",
 data: dataString,
 cache: false,
 success: function(){
 //alert(dataString);//is not empty
 getData();
 }
});
return false;
});

function getData()
{
   $.ajax({ 
      type: "GET",    
      url: 'get-data.php',                                                                   
      success: function()          
      {
      var jq = '<?php echo $_POST['msg_id'];?>';   
      alert(jq);      
      } 
    });
}

and function data to retrieve the just posted data but the var jq has no post data.What could be the cause?.

  • 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-06T12:54:13+00:00Added an answer on June 6, 2026 at 12:54 pm

    Being that you’re using jQuery (or any JavaScript) you don’t embed PHP code into it…

    Assuming that you’re only wanting to return the msg_id and nothing else your get-data.php would be something like this:

    <?php
      // all the database work here to obtain the id..
    
      echo $data['msg_id'];
    ?>
    

    Which would then turn your getData function to this:

    function getData()
    {
       $.ajax({ 
          type: "GET",    
          url: 'get-data.php',                                                                   
          success: function(jq)          
          {
          alert(jq);      
          } 
        });
    }
    

    Now, to expand on this — if your return is going to be some sort of an array you’ll want to use json_encode in your php… like so:

    <?php
    $data = mysqli_fetch_array(mysqli_query("SELECT * FROM table"), MYSQL_ASSOC);
    
    echo json_encode($data);
    ?>
    

    Which logically, because we’re returning a json array our JavaScript also changes:

    function getData()
    {
       $.ajax({ 
          type: "GET",    
          url: 'get-data.php',                                                                   
          success: function(response)          
          {
          var jq = $.parseJSON(response);
          alert(jq.msg_id);      
          } 
        });
    }
    

    Not much of a difference between the two.. But hopefully this answer has put you further on the path to an enlightened understanding of the tools you are attempting to use.. There are plenty of jQuery tutorials out there if you only google for them… Many JavaScript die hards (myself included), will urge you to learn Native JavaScript so that you can understand what is happening behind the scenes of jQuery. It is a very good idea to do, and again there is a lot of information and tutorials about it if you google for it.

    I’m sure some people have some books they can recommend for your reading as well..

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

Sidebar

Related Questions

i'm using this code to post to a php page: var qreq = .....myurl.php;
I am using this code if form.is_valid(): form.save() if request.POST.get('ajax') == 'true': return HttpResponse('Data
I am using jQuery's $.post function to retrieve some data from a php file,
i'm using this code to post to my application page: $page_info = $facebook->api(/344722062246773?fields=access_token); $attachment2
I've tried to move WCF to NetDataContractSerializer using the code in this post: http://lunaverse.wordpress.com/2007/05/09/remoting-using-wcf-and-nhibernate
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:
Using This code: I am tring to fill the page with the data and
Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
While using this code to serialize an object: public object Clone() { var serializer
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1

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.