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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:22:22+00:00 2026-05-23T09:22:22+00:00

Ok so i am trying to retrieve data from an ajax request and possibly

  • 0

Ok so i am trying to retrieve data from an ajax request and possibly if possible set a php array …I am not even sure if this is possible considering one is client side and one is server side…so here is my code

on the html page

<?php foreach ($products as $product): ?>
  <li>
  <h3><span><?php print $product["price"]; ?></span> (4) <?php print $product["name"]; ?> </h3>
    <div class="container">
 <table  width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
 <td valign="top" width="42"><span class="qty"><?php print $product["quanitity"]; ?></span></td>
 <td width="180">
 ........  

and I want to loop through all the products in this array but to get the products I need to make an ajax call like this

$.ajax({
    type: 'post',
    url: "/shop_systems/index.php?route=module/cart/get_all_products",          
    dataType: 'json',
  data: {current : null, previous : these_ids, quantity : 1, multiple : true},
    success: function (data) {

I was thinking if there was an easy way to do this ….I was thinking that one solution would be to write the html in the success part of the ajax call but I would have lots of append statements…any cleaner way would be appreciated

  • 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-23T09:22:22+00:00Added an answer on May 23, 2026 at 9:22 am

    Use cURL with PHP

    PS: I recommend not mixing your html and php like you are. It is needlessly hard to debug and maintain.

    You can use this code (not tested but should work):
    Note: make the URL an absolute URL or it won’t work

    $post_data = array(
        'current' => 'null',
        'previous' => 'null',
        'quantity' => '1',
        'multiple' => 'true'
    );
    
    // Init curl thing
    $ch = curl_init();
    
    // Setup curl options
    curl_setopt_array($ch, array(
        CURLOPT_URL => '/shop_systems/index.php?route=module/cart/get_all_products',
        CURLOPT_POST => TRUE,
        CURLOPT_RETURNTRANSFER => TRUE, // Return content as string
        CURLOPT_FOLLOWLOCATION => TRUE, // Follow redirects
        CURLOPT_AUTOREFERER => TRUE, // Set referer field on redirect
        CURLOPT_VERBOSE => TRUE,
        CURLOPT_COOKIEJAR => '/tmp/curl_php_cookies',
        CURLOPT_COOKIEFILE => '/tmp/curl_php_cookies',
        CURLOPT_STDERR => fopen('/tmp/curl_php_log', 'w'),
        CURLOPT_POSTFIELDS => $post_data
    ));
    
    // Excecute request
    $product = json_decode(curl_exec($ch));
    
    $html = '';
    
    foreach ($products as $product)
    {
        $html .= <<< HTML
        <li>
            <h3>
                <span>{$product["price"]}</span> 
                (4)  {$product["name"]}
            </h3>
            <div class="container">
                <table  width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
         <td valign="top" width="42"><span class="qty">{$product["quanitity"]}</span></td>
         <td width="180">
    HTML;
    }
    
    ?>
    

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

Sidebar

Related Questions

I am trying to retrieve the values from the following url: http://rentopoly.com/ajax.php?query=Bo . I
I am trying retrieve data from a .php file on a server from within
I'm trying to retrieve some data from a JSON response, but this doesn't seem
I am trying to display JSON data that I retrieve from an ajax call
I am trying to retrieve data from MySQL for a flash application via PHP,
I am trying to figure out how to retrieve data from a MySQL database
I'm trying to retrieve JSON data from a remote site with Rails/Prototype. I've found
I'm using a jQuery ajax json call to retrieve a 3 dimensional PHP array
I'm trying to get a simple GXT application to retrieve data from an external
Hi i am trying to retrieve data from mysql database to create flot graph

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.