I would like my JavaScript to use the PowerShell output, which is in JSON format, so I can draw a Google data table.
I have tried using window.clipboardData.getData('Text') but it doesn't seem like the answer I'm looking for and for some reason setTimeout() isn't working anymore. I have also tried event.dataTransfer.getData('Text') but I received an error
SCRIPT5007: Unable to get property 'getData' of undefined or null reference.
I kind of don't like having to copy to the clipboard because PowerShell does not take the same amount of time to finish executing every time. Additionally, the Google portion of the code constantly responds with error Invalid JSON string even though when I manually pasted the code, the data table loaded perfectly. I'm running on IE11.
You can install a HTTP server (like Apache or Lighttpd) on your computer and dump your JSON output in a .json file in the HTTP server directory.
Then you can make an ajax HTTP request to retrieved the file everytime you need it.
Related
I am new to Perl and I just copied the Cleb answer (https://stackoverflow.com/a/28992992/5553963) (and also made the ajax.pl executable) but it doesn't work and it gives this error:
XML Parsing Error: not well-formed
Location: file:///home/workspace/snmp-agent/query_ui/ajax.pl
Line Number 1, Column 2:
When I run the ajax.pl there is no error but when I get the query via Ajax I faced above error and as you can see from Cleb answer the first line is: "#!/usr/bin/perl".
Can someone please give me a hint how to solve this?
CGI programs need to be executed by a web server (which has to be properly configured to execute CGI programs).
You are opening the file directly in a browser from the filesystem (we can tell because the Location is a file: scheme URL) and it is trying to parse it as XML (possibly you have associated pl files with the XML mime type in your OS somehow). Since it isn't XML, it fails.
Pick a web server, install it, and consult its manual on how to configure it to run CGI programs.
I have an jQuery('#Frame').animate360 script on page and it calls a file called Profile.xml to get its settings etc.
Problem is Profile.xml is on Azure Blob and is in uppercase (PROFILE.XML). This means a 404 file not found error.
I can't change filename(Profile.xml) on azure.
The piece of JS that calls the Profile.xml seems to be encrypted in a library (HTML5Loader.js) i.e. The text 'Profile.xml' does not appear in any file and can only be found with chrome debugger in an unnamed file.
My instinct was to use something like Application_BeginRequest etc to catch a 'call' to https://storageblabla.blob.core.windows.net/uploads/ALPHA/3DIMAGES/1.010659/Profile.xml
and change it to ...../PROFILE.XML
but it's to late at that stage. It already knows that its a 404.
There must be some access, with code, to a point where a remote url is being called that can be intercepted.
Rekon its a one line fix but I just can't find the right term to search on.
I'm having a problem when sending large amounts of data through an AJAX request. I'm pulling in an XLS file from a website and attempting to pass it through an API by parsing the data. I'm doing this in VBScript/Classic ASP so there is no native function to parse XLS so I'm first attempting to convert it to a CSV file through Javascript.
I'm using something called SheetJS (http://oss.sheetjs.com/js-xls/) which is a great tool and it works just as I need it to. I can run an Excel file through it and it outputs the correct CSV data. I then try to send that data via AJAX to the ASP page with my code and I get a 500 error that I've isolated to being an issue with the file being too large. I was able to isolate to about 1652 lines of my Excel file and anything past that generates a CSV file too large to send.
All I am getting is a 500 error so I'm not really sure what else to do from this point. Is there a data limit on AJAX functions? Or is it a time limit type issue? I don't know how to find out which it is. Any suggestions on how to get a more detailed error message AND any fixes for this issue?
While you can't work with .xls files natively in VBScript, there is ADO that makes it easy to do that via COM. This way scales well wrt memory. Start your research here.
I have a Python program that generates an html page for reporting results. The html page is saved in an output directory on disk alongside a javascript file that helps with dynamic table handling. I also save a JSON file to this output directory that I would like to read in with my javascript file. This JSON file has data from the Python run (saved dictionary) that I would like to be able to access. So in an output directory on disk I have:
C:/somedirectory/output/report.html
C:/somedirectory/output/tables.js
C:/somedirectory/output/data.json
All files have been created from my program.
My html page has a table with checkboxes and if those checkboxes are selected I would like to update a second table based on data saved in the JSON file. Thus I would like to open my html report in any browser and read in the JSON file as a javascript object.
I have been trying to use ajax and .getJSON but am getting the
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
I have searched and seen many similar problems but have not come across anything that quite fits what I need. Thoughts and a work around would be greatly appreciated. Thanks.
Update
Since everything is run locally on the client side I have decided to embed the JSON data (python dictionary) and javascript code directly into the html report output. This way the data is internally accessible and the html file can be passed around without dependency issues. The user with the answer I selected below has a link that eludes to this solution.
JavaScript runs on the client machine, hence it can only access files on the client machine using a special setup.
If you want it to read JSON on your server, you should use the path:
http://example.com/output/data.json
Better way would be to read/write JSON file from Python and then send the table data to JavaScript as in this answer: Send data from Python to Javascript (JSON)
I'm loading a large number of items on a page through JSON, but it isn't working. This is my first time using JSON and I figured JSON was just a big object so I copied my object that I had before in a variable into a file and names it fun.js.
You can check out the JSON here:
http://justpaste.it/15zc
I'm using jQuery to get the JSON:
$.getJSON('fun.js', function(data){
alert(data)
});
Nothing is being alert, in the matter of fact...the alert isn't happening at all. Anyone know why?
For starters, your JSON doesnt validate. Go paste it here and fix your errors: http://jsonformatter.curiousconcept.com/
Secondly, user jQuery.Ajax to which you can pass onError parameter so you'll get a warning that JSON didn't go through.
Have you validated that the JSON is the issue? Open up Firebug or Chrome Dev Tools and refresh the page. You may see a message that the file wasn't found or there was a parsing exception or a security error.
If the file isn't found, you can fix that in the code.
If there is a parsing error, use a JSON validator.
If there is a security issue, see my answer to Get a JSON file from URL and display. You need to update your server policy or configure your browser to allow access to file URL's in your tests through.