prototype problem

M

mambenanje

I am using the prototype ajax library but I realised that each time I
am calling the server for xml the new records get appended to the old
so when I display the xml data it shows the old ones and the new ones
appended. for example when i do a search on questions by calling a php
script the result will be displayed in a div area, when I make a new
search, the new results will be appended and that is all messy can
anyone help me out, I am using

// JavaScript Document
//questions model object
var Questions=Class.create();
Questions.prototype={
initialize: function(control,url){
this.control=control;
this.url=url;
this.questionsPerPage=3;
this.currentPage=0;
this.questions=[];
this.questionsXML="";
document.questionClass=this;
this.paper=new Object();
},
//get question query to server
getQuestions: function(params){
ajax=new Ajax.Request(this.url,
{
method: 'get',
parameters: params,
onComplete: this.paperLoaded
});
},
paperLoaded: function(xhr){
alert(xhr.responseText);
document.questionClass.questionsXML="";
document.questionClass.questionsXML=xhr.responseXML;
document.questionClass.extractQuestions();
document.questionClass.showQuestions();
},
//convert xml of question to array
extractQuestions: function(){
//extract paper properties
var par=this.questionsXML.getElementsByTagName('questions');
this.paper.level=par[0].getAttribute('level');
this.paper.subject=par[0].getAttribute('subject');
this.paper.year=par[0].getAttribute('year');
this.paper.paper=par[0].getAttribute('paper');
alert(this.paper.level);
//extract questions from xml cross browser purpose use get tag names
var ques=this.questionsXML.getElementsByTagName('question');
//extract all question from ques forming an object then add it to
questions array

for(i=0;i<ques.length;i++){
obj=new Object();
obj.name=ques.getAttribute('name');
obj.questionId=ques.getAttribute('questionId');
obj.question=ques.firstChild.nodeValue;
this.questions=obj;
}

my problem is with the extractquestions functions where I get the
result and output but it adds the old ones
 
T

Thomas 'PointedEars' Lahn

I am using the prototype ajax library [...]

Prototype.js is junk; please do not ask about it here. It is only
a pity that one cannot filter out all postings with a Subject header
containing "prototype". Because the languages discussed use a
prototype-based object model -- one that Prototype.js ignores,
despite its name.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top