opencart 2.0 SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data OK

一曲冷凌霜 提交于 2021-01-27 03:50:40

问题


I looked all over the internet and found no answer.

Basically my problem is whenever I try to edit orders and change stores I get the SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data OK in firefox and in chrome I get SyntaxError: Unexpected end of input OK.

Has anyone found a "real" solution for this because I tried all that was suggested but they don't work. From changing the api_id to making a secondary API. And even the .htaccess method.


回答1:


I got the same error and found away to fix it:

  1. Login in the backend as admin and go to System > Users > Api
  2. Create a new api with a generated password and make sure it's enabled
  3. Go to your store settings (system > settings > Edit) and open the Option tab
  4. Scroll down till you find the 'checkout'
  5. Where it says 'API User' select the API User you just created
  6. Save the changes and your done!

You'll be able to edit the order status now!




回答2:


I happened to have the same update order issue.

If you tried every possible solution found on the Internet, but no one worked, maybe the bug is from your server provider.

In my case, the problem comes from $curl function, which used frequently on opencart 2.0.

You may paste this php file in your admin/controller/sale/ and then type your url :http://YOURDOMAIN.com/admin/controller/sale/test.php

    <?PHP
            echo "a<br/>";
            $curl = curl_init();
      //http://YOURDOMAIN.com testing"

            $aa='Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36 OPR/28.0.1750.48';
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLINFO_HEADER_OUT, true);
            curl_setopt($curl, CURLOPT_USERAGENT, $aa);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_URL,  'http://YOURDOMAIN.com/index.php?route=api/login');

            curl_setopt($curl, CURLOPT_POST, true);


            $json = curl_exec($curl);
            echo "server link to http://YOURDOMAIN.com/index.php?route=api/login <br/>";
            echo "Error Message:<br/>";
            print_r(curl_error($curl));
            echo "<br/>";
            echo "Response:";
            echo "<br/>";
            print_r($json);
            echo "<br/>";
            echo "<br/>";
            echo "<br/>";
            echo "<br/>";
            curl_close($curl);
            $curl = curl_init();
        //http://google.com"

            $aa='Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36 OPR/28.0.1750.48';
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLINFO_HEADER_OUT, true);
            curl_setopt($curl, CURLOPT_USERAGENT, $aa);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_URL,  'http://google.com');

            curl_setopt($curl, CURLOPT_POST, true);


            $json = curl_exec($curl);
            echo "server lint to http://google.com <br/>";
            echo "Error Message:<br/>";
            print_r(curl_error($curl));
            echo "<br/>";
            echo "Response:";
            echo "<br/>";
            print_r($json);
            curl_close($curl);
       ?>

If your browser message doesn't show this

a server link to http://YOURDOMAIN.com/index.php?route=api/login Error Message:

Response: {"error":"\u8b66\u544a\uff1a\u4e0d\u5339\u914d\u7684\u7528\u6236\u540d\u6216\u5bc6\u78bc\u3002"}

Then you may ask your server provider to help you setting the server, because this means your $curl could not link to your localhost and could not retrieve data from your localhost.

Hope this will help you !!




回答3:


I was able to solve this problem in 3 steps. In my case, i did upgrade my opencart database from 1.5x to 2.x with the standard (out of the box Opencart upgrade). I also had a multistore configuration. I was able to Edit orders once I run the following steps:

  1. Install OC2 (out of the box, no configuration) with the same admin credential as the one used in your legacy database. Export your database and find the place in the dump file (sql) where you have INSERT INTO api values (... line. This is the first command you need to run in you legacy database.

  2. UPDATE setting set value=1 where key = 'config_api_id';

  3. UPDATE store set ssl=url; However, this may not work if you are working on localhost. So for testing, I had to change it to UPDATE store set ssl = 'http://localhost/'; Do not forget the last backslash.

Please notice that you can also perform those operation on the admin user interface.




回答4:


I assume you are working with opencart 2.x version.please follow below step

1) check your oc_api (oc is opencart database prefix).there should be one record

if not please run below query

INSERT INTO oc_api (api_id, username, firstname, lastname, password, status, date_added, date_modified) VALUES (1, '2uVCDrqPBaq52KKCModEFFc7ILdMbKWulvbEsLkJVJHbm334HGQC5BDxoWlnXUwi', '', '', 'so49tj04Cv6yteAoZaZ3IzAfhYG7qWkOLavvIyejHPHEO7eQEn7mtgUFxT9JXQvwCD9b46gFjlrMGSWvHs1NrECiaHPOaCTNRjk8E64eY0nNVflHgpJrCgH3bw1K1rOf28iXkyquk76F8lNWUexCuzjGzU29pOhq1O3peiy4K6n07jMeeL0QzAZLkuPq0nMuNXmzvLV5GxreUZidCvPXSEmItDAPZ4Pp6Ys2aqOzbgJ9EISV6NCVIAM8ONIrVEqd', 1, '2015-01-27 16:38:49', '2015-01-27 16:38:49');

2) search config_api_id field into oc_setting table and enter its value 1 or run below query

UPDATE oc_setting SET value = '1' WHERE oc_setting.setting_id = 437;

Now check you admin and edit order. your problem will solve.

Thanks




回答5:


Ive had a lot of issues upgrading from opencart 1.5.1 to 2.0.1

Exactly the same symptoms as yours

SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

So I created a fresh database and a fresh install of opencart 2.0.1

Initially I had no issues with new orders but as more orders where added and history ammended I got the same eror intermittently.

The only way around this was to clear cookies, close browser , reboot the laptop i was using, use an alternative browser. or login to another computer to change the history status.

this message seems to just seem to come up randomly when opencart feels like it

Really I should have just stayed with old version i would have saved 3 days mucking about fixing 'issues' in a version thats obviously not ready for production yet.




回答6:


I had the issue, simple solution that works, try this:

Open Admin/Config.php

define('HTTPS_SERVER', 'http://yourdomain.com/admin/');
define('HTTPS_CATALOG', 'http://yourdomain.com/');

Change to the following:

define('HTTPS_SERVER', 'https://yourdomain.com/admin/');
define('HTTPS_CATALOG', 'https://yourdomain.com/');



回答7:


Try disabling maintenance mode. That worked for me!



来源:https://stackoverflow.com/questions/28053063/opencart-2-0-syntaxerror-json-parse-unexpected-end-of-data-at-line-1-column-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!