Can't load ajax datatable with HTTPS

Can't load ajax datatable with HTTPS

hfmiguelhfmiguel Posts: 2Questions: 1Answers: 0

Hello, I'm using datatables for an admin panel of my app (PHP - Laravel) and I'm using Ajax loaded datatables but encountered this error when I deployed on the server:

Mixed Content: The page at 'https://testapp/admin/storage/3/edit' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://testapp/api/storages/templates?templates=&storage_id=3&_=1642700739549'. This request has been blocked; the content must be served over HTTPS.

This is my code for the table:

` var table = $('#productsTable').DataTable( {

            ajax: '/api/storages/templates/?templates=' + storage_template_select.val()+'&storage_id='+storage_id,

            columns: [
                { 
                    "data": "checked",
                    "render": function(data, type, row, meta){
                        if (data) {
                            data = '<input type="checkbox" product_id="'+row.id+'" row_id="'+meta.row+'" checked>'
                        }else {
                            data = '<input type="checkbox" product_id="'+row.id+'" row_id="'+meta.row+'">'
                        }

                        return data;
                    }
                }, 
                { 
                    "data": 'name' 
                },
                { 
                    "data": 'quantity',
                    "render": function(data, type, row, meta){
                        data = '<input class="form-control form-control-sm quantity-row'+meta.row+'" type="number" step="1" min="1" value="'+data+'" product_id="'+row.id+'" row="'+meta.row+'">'

                        return data;
                    }
                }
            ],
            fnDrawCallback: function(oSettings) {
              updateStringProducts();
            }                    
        } );  `

I've tried hardcoding the HTTPs into the ajax url but it always returns the same error. I'm kinda lost. Any help would be appreciated.

Thanks.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 15,820Questions: 25Answers: 3,751
    Answer ✓

    See if this SO Thread helps.

    Kevin

  • hfmiguelhfmiguel Posts: 2Questions: 1Answers: 0

    Woah, that was fast. I think it worked. Must be the only solution I haven't tried because I was on SO for so much time. Thank you!

Sign In or Register to comment.