Troubleshooting error returning json when acessing db table

Message returned from system is:

Headers: 200 ok
Response: JSON.parse: unexpected character at line 1 column 1 of the JSON data.
(Response Payload: 1 No such file or directory)

Now; you’d expect this to be enough information, but all the code works perfectly on a different hosting service. One thing that I know nothing about is whether I need to sign into the database in order to access it. My alternative host doesn’t require a login procedure.

This is the code I currently use to get all data, successfully from another host, from the named table:

$.getJSON(url, function(data) {
var val= data;
var panelV=(data[‘MSB_Front’][(Object.keys(data[‘MSB_Front’]).length)-1][‘panelVoltage’]);

N.B. I include the following in the file that makes this request to the server - index.html:

		"\<script src='",
		("https:" == document.location.protocol) ? "https://" : "http://",
		"' type='text/javascript'>\<\/script>" 


Likely due to this


Thanks for the reply.

I think that given your view here, and my earlier difficulties with creating the db, I’m going to have to move on.

Thanks again :slight_smile:

1 Like

I recognize this error message from here:

So I think the reason your JSON cannot be parsed is because your code is returning the database error message which is not valid JSON data.

And this error message is caused by using the database hostname localhost, instead of the hostname that’s shown in the client area and control panel.

This would also explain why your code works on other hosting providers: must providers use localhost for the database hostname. But you’ll need to change that setting to connect to your database here.

Besides this, I see absolutely no problem in hosting your website!


Thanks for the insight - much appreciated. I’ve just reactivated my account and will have another attempt based on your insights.

Thanks again!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.