Ajax request does not work on page SHOP > 3 COLUMNS > LEFT SIDEBAR

5 replies · opened Nov 4, 2018

MmgpoliveiraNov 4, 2018

Hi

I would like you to help me solve this problem. The Ajax request below, meant to list product items from a php file does not work when I put it after the <body> tag in the file shop-3-left-sidebar.html however it works when I place between the <head> tags. Thank you.

&lt;script&gt;

    // Show items
    $.ajax({
      type: "GET",
      url: "ajax/products.php",
      data: { department: &lt;?php echo $_GET["department"]; ?&gt;, category: &lt;?php echo $_GET["category"]; ?&gt; },
      success: function(result){
          $("#shop").html(result);
      },
      error: function(){
          alert('Error');
      }
    });

&lt;/script&gt;
MmgpoliveiraNov 5, 2018

Are you going to answer my question, please?

SSemicolon WebSTAFFNov 8, 2018

Hello,

Please provide us with a Live URL so that we can check out the exact issue and provide you with a more accurate solution for this. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

MmgpoliveiraNov 9, 2018

Hello,

This the page where I want the items to be loaded from an ajax request.

You may see the AJAX jQuery script right before the closing </head> tag in the source code.

The items are not being loaded and shown in the page as they should be. It may happen the items to be shown at a first page load, however they are no more loaded and shown when you refresh the page.

I need the script working in the <section id=”content”> of the page because I put the header and footer in separate PHP files and create different pages for the content section.

The ajax script works well in other HTML5 themes which I use but it is not working in yours.

Follow as attachment the items as it should be displayed in the page.

Thank you in advance for your help

SSemicolon WebSTAFFNov 12, 2018

Hello,

Thanks for your Patience!

Please consider using the following code:

jQuery.ajax({
  url: "ajax/produtos.php",
  success: function(result){
	  jQuery("#shop").html(result);
  },
  error: function(){
	  alert('Erro');
  }
});

This should definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard