views:

58

answers:

2

I use Cytoscape Web for generating gene maps. It needs string to draw and I have XGMML files so I used JQuery for getting the XGMML file and turning them into strings. Here is my codepiece:

$.get("ENSG00000148606.xgmml", function(data) {
      if (typeof data !== "string") {
       if (window.ActiveXObject) { // IE
        data = data.xml;
       } else {
        data = (new XMLSerializer()).serializeToString(data);
       }
      }
      vis.draw({ network: data }); //Line that draws the map. It's from Cytoscape Web.

     }); 

it works perfectly on IE but when I try other browsers, I'm getting nothing. I tried to figure out what's wrong via alert(data); and I get an empty alert box for all browsers except IE.

Any ideas?

A: 

I'm not sure if all browsers have implemented XMLSerializer. Perhaps you can parse your data with a 3rd party library or roll your own.

frbry
A: 

Have you tried $.ajax instead of get. It will help to make sure that the data is indeed recognized at XML before serializing it.

$.ajax({
    url: 'ENSG00000148606.xgmml',
    type: 'GET',
    dataType: 'xml',
    timeout: 1000,
    error: function(){
        alert('Error loading XML document');
    },
    success: function(data){
        data = (new XMLSerializer()).serializeToString(data);
        vis.draw({ network: data});
    }
})
Paul
Actually I did and it worked! Thanks a lot.
Ali Teoman Unay