473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

prototype problem

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.responseXM L;
document.questionClass.extractQuestions();
document.questionClass.showQuestions();
},
//convert xml of question to array
extractQuestions: function(){
//extract paper properties
var par=this.questionsXML.getElementsByTagName('questi ons');
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('quest ion');
//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[i].getAttribute('name');
obj.questionId=ques[i].getAttribute('questionId');
obj.question=ques[i].firstChild.nodeValue;
this.questions[i]=obj;
}

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

May 15 '06 #1
1 1314
ma********@gmail.com wrote:
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
May 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: stephane | last post by:
Hi all, What I am trying to achieve is an 'inherits' method similar to Douglas Crockford's (http://www.crockford.com/javascript/inheritance.html) but that can enable access to the superclass'...
4
by: jemptymethod | last post by:
http://htmatters.net/htm/1/2006/01/EIBTI-for-Javascript-explicit-is-better-than-implicit.cfm
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
6
by: mmcloughlin | last post by:
I'm learning about objects and am trying to figure out how basic inheritance works. I've got into the habit of explicitly setting the prototype object with an object literal as it seems to make the...
5
by: Gerry Vandermaesen | last post by:
Hi, Does anyone have a freely available JavaScript JSON stringifier. So far my search has been in vain, the one offered on http://www.json.org/json.js does not seem to work for me.
8
by: Chad Burggraf | last post by:
Hi all, I'm brand new to this newsgroup. I've been reading the FAQ's and some other documentation submitted by regulars of the group (such as "Javascript Best Practices" at...
6
by: burningodzilla | last post by:
Hi all - I'm preparing to dive in to more complex application development using javascript, and among other things, I'm having a hard time wrapping my head around an issues regarding "inheritance"...
2
by: beseecher | last post by:
Hi, In my research in the javascript language I have encountered problems with implementing prototype inheritance while preserving private methods functioning properly. Here is an example: ...
2
by: hzgt9b | last post by:
I know how to overwrite a function. Normally this is what I would do: function someFunction() { /* orig definition here */ } //later in the execution stream I would do... someFunction = function...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.