/    Sign up×
Community /Pin to ProfileBookmark

Novice needs help

Hi,

Someone has written some code for me to upload XML data onto a website. It seems to write OK if the XML file is fairly small but if it is large the file upload partially.

Below is the .js function…the question is what do I have to modify to upload any filesize

[code]
//dataset load function
$(document).ready(function()
{
//get params
var params = extractUrlParams();
var dataset = params[“dataset”];
var folder = params[“month”];

//load XML
docXml = new ActiveXObject(“Microsoft.XMLDOM”);
docXml.load(‘xml/archive.xml’);
//get folder and month data
var folderNode = docXml.getElementsByTagName(‘folder’);
var monthNode = docXml.getElementsByTagName(‘month’);

//if first visit, get latest date
if(!folder)
folder = folderNode[folderNode.length-1].firstChild.nodeValue;
//else it is an archive
else
{
folder = unescape(folder);
//update links to keep the selected date
$(“ul#menu > li > a”).each(function(i)
{
var href = $(this).attr(“href”);
$(this).attr(“href”, href+’&month=’+folder);
});
}

//retreive proper date name
for(i=0;i<folderNode.length;i++)
{
if(folderNode[i].firstChild.nodeValue == folder)
var folderDate = monthNode[i].firstChild.nodeValue;
}
//add date to title
$(“#date”).text(folderDate);

if(!dataset)//home page
{
document.title = “Amey Rail Management Pack”;
$(“#contentH1 > h1”).text(“Amey Rail Management Pack”);
}
else//content page
{
dataset = unescape(dataset);
//hide current link
$(“ul#menu > li#”+dataset).hide();

//set titles
document.title = “Amey Rail Management Pack | “+dataset;
$(“#contentH1 > h1”).text(dataset);

//loadContent
loadData(dataset,folder);
}

//populate archive list
for(i=0;i<folderNode.length;i++)
{
var opt = jQuery(‘<option value=”‘+folderNode[i].firstChild.nodeValue+'”>’+monthNode[i].firstChild.nodeValue+'</option>’);

if(monthNode[i].firstChild.nodeValue == folderDate)
{
opt.attr(“selected”, true);
}
opt.appendTo(“#archiveList”);
}
$(“#archiveDiv”).addClass(“right”);

//archive change handling
$(“#archiveList”).change(function()
{
//get dataset
var params = extractUrlParams();
var dataset = params[“dataset”];

//change month value
if(!dataset)
window.location =’?month=’+$(this).attr(“value”);
else
window.location =’?dataset=’+dataset+’&month=’+$(this).attr(“value”);
});
});

//function to manage data display
function loadData(dataset,folder)
{
docXml = new ActiveXObject(“Microsoft.XMLDOM”);
docXml.load(“xml/”+folder+”/”+dataset.split(‘ ‘).join(”)+”Data.xml”);

var XMLdataSet = docXml.getElementsByTagName(‘testData’);
var table = jQuery(“<table id=’table’></table>”);
table.appendTo(“#dataContainer”);

readNodes(XMLdataSet[0],1,1);
}

//readNodes
function readNodes(dataSet,rowNum,dataNum) //recursive function to read the xml file
{
//if node has child
if(dataSet.hasChildNodes())
//call function on first child
readNodes(dataSet.firstChild,rowNum,dataNum);

//if node has no child
else
{
//action
if(dataSet.nodeValue)
inputData(dataSet.nodeValue,rowNum,dataNum);
else
inputData(0,rowNum,dataNum);

//if node has brother
if(dataSet.parentNode.nextSibling) //call function on brother — data level
{
dataNum++; //increment data number
readNodes(dataSet.parentNode.nextSibling,rowNum,dataNum);
}

//else, if parent node has brother
else if(dataSet.parentNode.parentNode.nextSibling) //call function on parent’s brother — row level
{
rowNum++; //increment row number
dataNum = 1; //reset data number
readNodes(dataSet.parentNode.parentNode.nextSibling,rowNum,dataNum);
}
}
}

var currentRowNum = 0;

function inputData(value,rowNum,dataNum)
{
if(rowNum != currentRowNum)
{
var row = jQuery(“<tr id=’row”+rowNum+”‘></tr>”);
row.appendTo(“#table”);
currentRowNum = rowNum;
}

if(rowNum == 1)
var column = jQuery(“<th>”+value+”</th>”);
else
var column = jQuery(“<td>”+value+”</td>”);

column.appendTo(“#row”+rowNum);
}

function extractUrlParams()
{
var t = location.search.substring(1).split(‘&’);
var f = -1;
if(t)
{
f = [];
for (var i=0; i<t.length; i++)
{
var x = t[ i ].split(‘=’);
f[x[0]]=x[1];
}
}
return f;
}[/code]

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@chaz2290Nov 17.2009 — can't see anything you can change sorry, I think it will be something you need to add rather than modify.

I'd put it in the javascript section...
×

Success!

Help @patrick_p spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...