I'm getting XML data via jQuery, but the XML I am using has 5,000+ pieces of data I want to get. When my page tries to get the data after a few seconds my page freezes and shows "This page is being slowed down" and then crashes.
Is there a way I can get the data without the page crashing? Maybe slow the process down so it doesn't handle so many processes at once? Here is the code I'm using to get the XML data:
$(document).ready(function() {
$.ajax({
type: "GET",
url: "mymxl.xml",
dataType: "xml",
success: function(xml) {
$(xml).find("programme").each(function() {
$("xmlcontent").append($(this).find("title").text());
});
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
});
Related
I feel like I am spending too much time for this.I am getting an xml document from a database with an ajax call .The result is in an XML format ,instead of displaying it, I need to have the user download it.
Is there any way to do this that will work both in IE, FF and Chrome ?
function DownloadXML(XML_ID) {
$.ajax({
url: 'webservices/DownloadXML.svc/' + XML_ID,
method: 'GET',
dataType: "text",
success: function (data) {
//download xml here
},
error: onError
});
}
im creating a service that will transform html to pdf.
Request with parameter(HTML code to be transfered into PDF) ist send with ajax post.
On server side generating pdf file is no problem.
I was trying to send it back with JSON but i figured out that its not a good idea.
So now im sending it back with no changes - full pdf file as it was generated
...
$pdf->Output('out.pdf', 'I');
And here comes the tricky part.
What can i do with it on client side?
I was trying to show it or download it but i could not figured out how.
$.ajax({
type: 'POST',
url: service_url,
data: out,
success: function (data) {
// WHAT SHOULD I DO WITH "data" IF I WANT TO SHOW IT?
error: function () {
alert("Error");
}
});
Thanks
a wild guess would say that you need to create a PDFObject and then throw it into the Ajax.
HTML
<object id="pdf" data="myfile.pdf" type="application/pdf" width="100%" height="100%">
It appears you don't have a PDF plugin for this browser.
No biggie... you can click here to
download the PDF file.
</object>
and in the Ajax you would have to do something like :
$.ajax({
var pdf = $("#pdf");
type: 'POST',
url: service_url,
data: out,
success: function (data) {
pdf.show();
error: function () {
alert("Error");
}
});
I am trying to reload only part of a html page using jquery after a ajax call and everything I've tried gets me 404 not found. Does the jquery.load not work with node js and if so what is a workaround to get one div to reload without reloading the whole page?
$.ajax({
url: "http://localhost:3000/high",
type: "GET",
datatype: "jsonp",
success: function(data){
console.log(data);
var highbtn = JSON.parse(data);
console.log(highbtn);
$('#high').load('/Public/userphotoview.ejs' + ' #high');
},
error: function(){
console.log("error fetching data");
}
I want to load source code from a url, process its content and then load the url (with the processed info) to the user. How can that be done? (Is it possible using Javascript?)
Thank you in advance!
You need ajax. Using jQuery:
$.ajax({
type: "GET",
url: "your url",
success: function(data) {
alert("OK");
},
error: function(error) {
alert("error");
})
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.
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);