Post by capte » Mon Oct 10, 2011 10:48 am

I've been working on a script on opencart that uses jquery $.post .

Code: Select all

$(document).ready(function() {
        $(function() {
            $("#contentLeft ul").sortable({
                opacity: 0.6,
                cursor: 'move',
                update: function() {
                    var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
                    $.post("updateDB.php", order, function(theResponse) {
                        $("#contentRight").html(theResponse);
                    });
                }
            });
In opencart i've created a function in the model that contains what should be in updateDB.php
I was hoping to get this function to be called instead of an external page(updateDB.php)
and without reloading the current page.

Maybe .post is not the one i should use or is it?

Any idea would be appreciated.

New member

Posts

Joined
Tue Sep 20, 2011 9:27 pm

Post by Xsecrets » Mon Oct 10, 2011 1:20 pm

your problem is that you shouldn't create it in the model. You can only call controllers directly not models. You need to create a function in the controller which accesses the function you created in the model. then call that function from the controller. Lets say you create an update function in category controller then you would call index.php?route=product/category/update

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by capte » Tue Oct 11, 2011 11:07 pm

Ok my bad... It is in the controller.

But the trouble is that it's in the admin part of the website.
So I guess I will have to pass the token too ?

index.php?route=catalog/category/update&token=' . $this->session->data['token'];

New member

Posts

Joined
Tue Sep 20, 2011 9:27 pm

Post by hotwebideas » Wed Oct 12, 2011 12:55 am

capte wrote:Ok my bad... It is in the controller.

But the trouble is that it's in the admin part of the website.
So I guess I will have to pass the token too ?

index.php?route=catalog/category/update&token=' . $this->session->data['token'];
capte, I did this too. When I need the same functionality in the front end and admin, I usually write the model or controller function in the back end admin and then just path it from the front end. I never need a token when I do it that way. I hope that gives you some insight.

Bruce

New member

Posts

Joined
Wed Jun 29, 2011 11:44 pm
Who is online

Users browsing this forum: Baidu [Spider] and 11 guests