Using AJAX plugin

I am trying to use the AJAX plugin, but I seem to be missing something. The default URL (https://raw.githubusercontent.com/ryantxu/ajax-panel/master/static/example.txt) works fine, but when I add my own I get an error:

{
 "data": null,
 "status": -1,
 "config": {
  "method": "GET",
  "transformRequest": [
   null
  ],
  "transformResponse": [
   null
  ],
  "jsonpCallbackParam": "callback",
  "url": "https://<my site>/version",
  "headers": {
   "Accept": "application/json, text/plain, */*"
  }
 },
 "statusText": ""
}

The version file is just a single line of text and curl https://<my site>/version from my Grafana host returns what I expect.

Are you getting a cross-origin (CORS) error? Or are there any errors in the console? The above error doesn’t really say anything.

@daniellee that’s all I’ve got

Aha, you are just looking at the error screen. I meant in the Chrome Dev Tools. Here is an example where I spelled localhost as locahost and I got an “ERR_NAME_NOT_RESOLVED” error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://buster.klaxoon.com/version. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

found my problem

Now to fix it :frowning:

Just so we do not have a repeat of https://xkcd.com/979/ here is my solution (for Nginx).

To you vhost conf add:

location /version {
    add_header 'Access-Control-Allow-Origin' '*';
}

1 Like

:grinning:

Great that you got it working!

how to change conf vhost on windows 10?