0

I am trying to publish a network with Cytoscape web (or cytoscape.js if possible.) Since my data is quiet huge i prefer to export it from Cytoscape desktop and grab it with ajax in my html. Before the last version of Cytoscape (v.3.1.0) i was able to export the network in .xml format using this:

$.ajax({
type: "GET",
url: "data.xml",
dataType: "xml",
error: function(){
alert("Error loading file");
},
success: function(data){
data = (new XMLSerializer()).serializeToString(data); 
});
vis.draw({ network: data });

and it was working just fine.

When I try to do the same thing with .json (either converted from .xml or exported as .cyjs from Cytoscape desktop) it doesn't work. I used a similar code for this:

    $.ajax({
            type: "GET",
            url: "data.json",
            dataType: "json",
                        error: function(){
                alert("Error loading file");
            },
success: function(data){
}
});
var netwdata = data.elements[0];
vis.draw({ network: netwdata });

Although I do not get a loading error, the network is not plotted now. I have no experience with .json so I am sure I am missing something. Any help or comment is welcome.

begum a.
  • 1
  • 1

1 Answers1

0

I think you didn't write serializer for json data. In simple words you didn't convert json object to string. Like you used for xml:

data = (new XMLSerializer()).serializeToString(data); 
Rai Ammad Khan
  • 1,521
  • 2
  • 14
  • 26
  • Nothing is automatic dude. You are just trying to become over clever. If it is the case then why serializer and deserializer funtions are written at first place? – Rai Ammad Khan May 26 '14 at 15:23
  • dude, calm down, JSON get's automagicly parsed by jQuery read the [api docs](http://api.jquery.com/jQuery.ajax/) by dataType – EaterOfCode May 27 '14 at 09:25