Install jsond php module

My website is using PHP 7.1. As I know, JSON had been removed because of some reasons, however, that doesn’t matter, I have an extension named JSOND to install on my localhost, which is exactly like JSON.
The problem is that I can’t install this extension on 000webhost, I can’t find a way to install it :frowning:, I tried to use JSON methods instead (json_decode instead of jsond_decode) but it still keep telling me I have called an undefined function :frowning:

Please help me to fix this :frowning:

Here the details:
Fatal error: Uncaught Error: Call to undefined function GuzzleHttp\json_decode() in /storage/ssd3/871/4200871/public_html/sort-section.php:26
Stack trace:
#0 {main}
thrown in /storage/ssd3/871/4200871/public_html/sort-section.php on line 26

@young666 Sorry for the inconvenience, 000webhost is intended for hobby/small projects, so it is limited. This is why you can’t install any extensions on 000webhost.
Consider a Premium Plan, which will solve you issue.
Check cheap premium plans here: Hostinger.

Hi @young666

But that’s weird you get the above error on json_decode function. Because it is a php’s default function.

Can you post your code?

2 Likes

Try this:-
Log in to your 000webhost account, then go to Settings >> General >> and set php version to “5.6”, now try again, see if it helps you. :slight_smile:

Below is the js code using ajax:

// Serialize the data in the form
        var sectionOrderJSON = JSON.stringify(sectionOrder);
        var subsectionOrderJSON = JSON.stringify(subsectionOrder);

        request = $.ajax({
            url: "sort-section.php",
            type: "post",
            data: { 
                sectionOrder: sectionOrderJSON,
                subsectionOrder: subsectionOrderJSON 
            },
            cache: false
        });

Here the php code to get the json data:

    $sectionOrder = jsond_decode($_POST['sectionOrder']);
    $subsectionOrder = jsond_decode($_POST['subsectionOrder']);

Yeah, I switched to version 5.6 and it gave me 502 Bad Gateway :frowning:

1 Like

How about using json_decode on the 5.6 version? :slight_smile:
And removing request =

I use “request =” to log the result into console on whether success or failure. And as above, I have switched to 5.6 version but the site gave me 502 Bad Gateway :frowning:

1 Like

@mantas.daraciunas @ledgr @teodor do you have any clue on why thhis is happening?

@young666

Did you try json_decode function?

Additionally, what is your web address?

1 Like

Yes, I did try json_decode.

Here my web address: https://pluperfect-leapers.000webhostapp.com/

Here the address I put the code: pluperfect-leapers.000webhostapp(.)com/manage-section.php (new user can’t post more than 1 link, sorry for this inconvenience).

The username and password is both “admin”.

Thanks for helping me :smiley:

Hi @young666!

Try changing to PHP 7.0

@young666
How to trigger the ajax? Is there a button to click?

1 Like

Yes, here is the button triggering ajax: @Supun

    $('#manage-section').submit(function (event) {

            // Prevent default posting of form - put here to work in case of errors
            event.preventDefault();

            console.log(sectionOrder);

            // Abort any pending request
            if (request) {
                request.abort();
            }

            // Serialize the data in the form
            var sectionOrderJSON = JSON.stringify(sectionOrder);
            var subsectionOrderJSON = JSON.stringify(subsectionOrder);

            request = $.ajax({
                url: "sort-section.php",
                type: "post",
                data: { 
                    sectionOrder: sectionOrderJSON,
                    subsectionOrder: subsectionOrderJSON 
                },
                cache: false
            });

            // Callback handler that will be called on success
            request.done(function (response, textStatus, jqXHR) {
                // Log a message to the console
                console.log("Saved!");
                alert("Đã lưu thành công!!!");
            });

            // Callback handler that will be called on failure
            request.fail(function (jqXHR, textStatus, errorThrown) {
                // Log the error to the console
                console.error(
                    "The following error occurred: " +
                    textStatus, errorThrown
                );
            });

            location.reload();
        });

Alright, and which button is it? :smile:

Here is the image for those of you who can’t find the button:
https://imgur.com/pWyeEsE

It won’t work, thanks anyway :frowning:

I do not understand the language of your website, which button should I click? :slight_smile:

2 Likes

Hey @young666

I found the button. Unluckily, we are having some troubles with our file manager right now. So that I can’t check your problem now.

Please keep patience. We will help you ASA the FM problem is fixed.

2 Likes

Yes, I’ll wait here, thanks a lot :smiley:

2 Likes

@young666
Is file manager working for you?