How to populate the Text Plugin from command line or API

I am using the Text Plugin to display a dynamic content. Manually populating the Text Plugin is not feasible. How can I update the Text in the Text Plugin by cmd, API ?

Thanks,

Yong

The Ajax Panel seems to be what you are looking for:

Thank you for the help!

I want to display a text/html in the Ajax and get the following error message:

http://www.taascloud.com:18081/xbo/_HenkinsOutput.txt will display text message. But I got the following error. Any suggestions?

{
“data”: null,
“status”: -1,
“config”: {
“method”: “POST”,
“transformRequest”: [
null
],
“transformResponse”: [
null
],
“jsonpCallbackParam”: “callback”,
“url”: “http://www.taascloud.com:18081/xbo/_HenkinsOutput.txt”,
“headers”: {
“Accept”: “application/json, text/plain, /
}
},
“statusText”: “”
}

Looks like the request is failing before a response is received.
If you use the http debugging tools in the browser, do you see any additional information?

Also, are you POSTing to avoid cache, or are you sending a body?
Just curious if you get the same result using a GET.
Or maybe this could this be a problem with accessing a non-ssl resource from an ssl resource?

I’ve also seen this error in IE where the webserver Keepalive is on, and a POST is executed before a GET in the keepalive duration. [not sure of the exact technical reason]

Here is the message I get from F12, when running grafana Ajax plugin from
my local machine. The URL request to localhost is initialized from
localhost.

XMLHttpRequest cannot load
http://localhost:18081/xbo/index.htm?from=1494802000704&height=160&to=1494823600704.
No ‘Access-Control-Allow-Origin’ header is present on the requested
resource. Origin ‘http://localhost:3000’ is therefore not allowed access

Thanks for the help.

This is the classic Cross Origin error (see CORS. When running localhost on different ports, the browser sees localhost:3000 and localhost:18081 as different domains and therefore blocks the request as a security feature.

If you are just testing locally, you can turn off CORS with this Chrome plugin. Just remember to disable it when you are finished testing as it will break other sites (like GitHub for example).

If you intend to have this on server with a domain then this will not be a problem. For example, http://myhost:3000 and http://myhost:18081 are seen as the same domain by the browser. Localhost is a special case.

Otherwise, the long term solution is to add a Access-Control-Allow-Origin header as the error says. I have no idea what application you have on port 18081 but most web frameworks support adding headers.

The CORS plugin solve the problem! Thanks for the help

I ran into the same problem again when I deployed the ajax plugin on the server. The problem can be framed as:

When creating an ajax plugin, the default URL (https://raw.githubusercontent.com/ryantxu/ajax-panel/master/static/example.txt) works just fine. The text display on the panel.

However, when I change the URL to mine (http://www.taascloud.com:18081/crowdcompass/bug.txt), the plugin display the follow error (CROS error)

{
“data”: null,
“status”: -1,
“config”: {
“method”: “GET”,
“transformRequest”: [
null
],
“transformResponse”: [
null
],
“jsonpCallbackParam”: “callback”,
“url”: “http://www.taascloud.com:18081/crowdcompass/bug.txt”,
“params”: {
“from”: “1464914490586”,
“to”: “1496450490586”,
“height”: 255
},
“headers”: {
“Accept”: “application/json, text/plain, /
}
},
“statusText”: “”
}

Any help will be greatly appreciated.

For those who ran into the similar situation, I have a workaround by enabling the CORS on the URL’s IIS Server.