Jump to content

Can i create invoice by ajax?


cools2

Recommended Posts

I create a file ajax.php in /includes/hooks

When I click on the button, I send ajax request to the file ajax.php, there I launch the localAPI function, but it does not work, what am I doing wrong?

How can i create invoice by ajax?

Link to comment
Share on other sites

I have main page home-page.tpl with button ( just for test ). 
Its look like this:

$('.submit').on('click', function () {
                jQuery.post('{$systemurl}includes/hooks/ajax.php', {action:'createInvoice'}, function(data) {
                    console.log(data);
                });
        });On the file ajax.php:
<?php
use Illuminate\Database\Capsule\Manager as Capsule;

if($_POST['action'] == 'createInvoice'){

    function getAdminUserName() {
        $adminData = Capsule::table('tbladmins')
            ->where('disabled', '=', 0)
            ->first();
        if (!empty($adminData))
            return $adminData->username;
        else
            die('No admin exist. Why So?');
    }

    $command = 'CreateInvoice';
    $postData = array(
        'userid' => '1',
        'status' => 'Unpaid',
    );
    $adminUsername = getAdminUserName(); 

    $results = localAPI($command, $postData, $adminUsername);
    print_r($results);
    die();
}

answer is : 500 (Internal Server Error)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated