highcharts prepare options for POST - asp.net

I need to send a Highcharts options object to an asp page so it can be written to a json flat file. These files are later passed to phantomjs via highcharts-convert in order to create some pdfs.
The problem however is stringifying the objects. I keep getting this error:
Uncaught TypeError: Converting circular structure to JSON
when I try this:
$.post("myASP.asp", JSON.stringify(myChart.highcharts().options));
There is a sample POST string here http://docs.highcharts.com/#render-charts-on-the-server but I'm not sure how to achieve that with mine. When I paste their sample into my code for testing I get all kinds of unescaped double quote errors. Is that a typo on their part?

I would check if there are curricular references in the JSON objects. As far as I remember that is not supported by the JSON serializer.
One example of this if you have an object with an array of children that refer back to the parent.
I think you can try the following:
{"infile":myChart.getSVG()}
This should get the svg representation of the chart

Related

Vscode settings problems

So I'm editing my settings in JSON and it all works well but this error keeps popping up:
"Expected comma jsonc(514)"
This is my code:
"css.lint.emptyRules": "ignore",
This is the whole json file just in case:
Whole Json file
You are missing a comma after the "gitlens.advanced.messages" object and before "css.lint.emptyRules": "ignore". That should solve your issue, also I highly advise you to take a look here JSON Syntax

Thymeleaf Pagination Url Failed to Convert String to Long

So I'm trying to paginate results where I have a page with a path variable, and the Thymeleaf th:href keeps telling me Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'
So I added an object called "StudySet" to the model in my controller method, like this
modelAndView.addObject("studySet", studySetById);
And then I try to use it in a th:href in my HTML like this
th:href= "#{${studySet.id}/?page=} + ${page}"
But my URL just shows up like this
http://localhost:8080/studySet/$%7BstudySet.id%7D/?page=2
When I want it to look like this
http://localhost:8080/studySet/8/?page=2
8 is the id of the "studySet" object.
So if anyone has any idea on what I'm doing wrong and could let me know, that would be awesome, thanks.
ok, I reproduced your problem and here is a solution:
th:href= "#{{studySetid}/?page={page}(studySetid=${studySet.id},page=${page})}"
here is a reference for further reading

Meteor: How to use object names including dashes in Spacebars

Didn't find the answer anywhere, but maybe one of you knows it.
I'm getting back data from http.call('GET'), I can use the data correctly in
Spacebars like
{{anydata.specificdata}}
but have no chance to use data w/ object names containing dashes like
{{anydata.specific-data}}
I tried
{{anydata.'specific-data'}}
, but this does not work either.
As I'm retrieving a lot of different data I would like to avoid to create helpers for every field containing dashes.
Does anyone know how I could handle something like
{{anydata.specific-data}?
Thanks for any answer that helps.
Have Fun!
I found the answer on a meteor form: https://forums.meteor.com/t/dash-character-in-spacebars/2885
I ran into a similar problem. I had a json object with a dash in a the variable name. In order to call an object with a dash, the following is done:
{{some.json.object.[with-a-dash]}}
Note the . before the open bracket and no quotes (single or double) around the dash named item.
on the HTTP success callback map the data object properties from dash to camelcase, then use your new object.
Some days offline behind...
I did not find a nice solution (due to the unexpectable combination of arrays and objects in the htpp result) but a working one:
I use EJSON.stringify() to stringify the http-result and replace the dashes in the object keys using a regular expression, then use EJSON.parse() to make it an object again. Done.
Not very elegant but working fine and fast.
Have Fun!

getting the content of an invalid Xml Document in Biztalk

I have a Biztalk orchestration that posts to a http site. the response that comes back is of xmlDocument type, but it only contains a 0, no html/xml at all. All I want to do is set that 0 to a string or something to output it, but I cannot use any of the xmldocument functions because the xml is not well formed, and I cant use maps because there is no schema to work with. Trying to use any xml function returns an "invalid root level" error.
You can use a string variable and use Xpath to set the value from the response message in an Expression Shape.
You can use a XMLDocument Message and create it in an Assign Shape. You can assign the string variable to an element in the message.
You might look at using a Pipeline Component to wrap the response - e.g. have a look at the Flat File samples here

parsing simple xml with jquery from asp.net webservice

I'm breaking my head over this for a while now and I have no clue what I do wrong.
The scenario is as followed, I'm using swfupload to upload files with a progressbar
via a webservice. the webservice needs to return the name of the generated thumbnail.
This all goes well and though i prefer to get the returned data in json (might change it later in the swfupload js files) the default xml data is fine too.
So when an upload completes the webservice returns the following xml as expected (note I removed the namespace in webservice):
<?xml version="1.0" encoding="utf-8"?>
<string>myfile.jpg</string>
Now I want to parse this result with jquery and thought the following would do it:
var xml = response;
alert($(xml).find("string").text());
But I cannot get the string value. I've tried lots of combinations (.html(), .innerhtml(), response.find("string").text() but nothing seems to work. This is my first time trying to parse xml via jquery so maybe I'm doing something fundemantally wrong. The 'response' is populated with the xml.
I hope someone can help me with this.
Thanks for your time.
Kind regards,
Mark
I think $(xml) is looking for a dom object with a selector that matches the string value of XML, so I guess it's coming back null or empty?
The First Plugin mentioned below xmldom looks pretty good, but if your returned XML really is as simply as your example above, a bit of string parsing might be quicker, something like:
var start = xml.indexOf('<string>') + 8;
var end = xml.indexOf('</string>');
var resultstring = xml.substring(start, end);
From this answer to this question: How to query an XML string via DOM in jQuery
Quote:
There are a 2 ways to approach this.
Convert the XML string to DOM, parse it using this plugin or follow this tutorial
Convert the XML to JSON using this plugin.
jQuery cannot parse XML. If you pass a string full of XML content into the $ function it will typically try to parse it as HTML instead using standard innerHTML. If you really need to parse a string full of XML you will need browser-specific and not-globally-supported methods like new DOMParser and the XMLDOM ActiveXObject, or a plugin that wraps them.
But you almost never need to do this, since an XMLHttpRequest should return a fully-parsed XML DOM in the responseXML property. If your web service is correctly setting a Content-Type response header to tell the browser that what's coming back is XML, then the data argument to your callback function should be an XML Document object and not a string. In that case you should be able to use your example with find() and text() without problems.
If the server-side does not return an XML Content-Type header and you're unable to fix that, you can pass the option type: 'xml' in the ajax settings as an override.

Resources