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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:37:47+00:00 2026-05-22T00:37:47+00:00

jQuery(document).ready(function(){ // Set the data text var dataText = { name: ‘John’, time: ‘2pm’

  • 0
jQuery(document).ready(function(){
    // Set the data text  
    var dataText = "
    { 
        name: 'John',
        time: '2pm' 
     }";  

    alert(dataText);
    // Create the AJAX request  
    $.ajax({  
        type: "POST",                    // Using the POST method  
        url: "/ajax/analytics/push",      // The file to call  
        data: dataText,                  // Our data to pass  
        success: function() {            // What to do on success  
             alert("Data Loaded: " + dataText);
        }  
    });  
});  
</script>   

hello im still learning ajax. how can we push a array of $_POST?

1.im trying to do something like

var dataText['name'] = 'Jhon';
var dataText['time] = '2pm';

then somehow turns it into

$_POST['name'] = 'Jhon';
$_POST['time'] = '2pm';

then send it to the url..

2.is there a way to debug this ? what im doing now is im writing

        # somehow doesnt work becouse its not auto refresh when the ajax sends a post
    var_dump($_POST);

        # ok heres how i debug it right now.
    ob_start();
    // write content
    $content = $_POST;
    ob_end_clean();
    file_put_contents('CACHE',$content);

in to a file, i hope there is a better solution for this..

Thankyou for looking in.
Adam Ramadhan

  • 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-22T00:37:48+00:00Added an answer on May 22, 2026 at 12:37 am

    I’m not entirely sure what you’re doing. You seem to be building JSON manually (and not doing it correctly) and then passing that (in the JSON-serialised string form) to your file. You then seem to expect it to be parsed by PHP automatically.

    It would be better to send it as key-value pairs. You can let jQuery do this for you if you pass in an object. This won’t look much different to your existing code:

    var dataText = 
    { 
        name: 'John',
        time: '2pm' 
    };  
    

    Note that I have removed the double quotes. This is primarily because it is illegal to have a JS string covering more than one line without escaping the line breaks. It is also because you want the object to pass into your $.ajax call.

    These should be available as $_POST['name'] and $_POST['time'] now.

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

Sidebar

Related Questions

I have the below code in my jqgrid <script type=text/javascript> jQuery(document).ready(function() { var grid
jQuery(document).ready(function(){ var panelContainer = jQuery('div#panels'); jQuery('<div id=tabs></div>').insertBefore(panelContainer); panelContainer.find('div.panel').each(function(n){ jQuery('div#tabs').append('<a class=tab href=#' + (n+1) +
<script type=text/javascript> jQuery(document).ready(function() { jQuery(.content).hide(); jQuery(.link).click(function() { jQuery(div.content).slideToggle(500); });; }); </script> How to expand
Please take a look at the following autocomplete code. $(document).ready(function(){ $(#the_input).autocomplete(/autocomplete.php, { //some options
In $(document).ready(), I am producing a model popup to add items on the page
I am having a small problem and i don`t know the reason. I set
How to use jquery scrolltop from jquery ajax handle page? page aa.html : <!DOCTYPE
I am studying jquery, I want make a effection as: first click, slider down
I have try to post value from page a to page b via jquery
I have created a menu using CSS and Javascript. When I click on a

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.