473,569 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.proto type={
initialize: function(contro l,url){
this.control=co ntrol;
this.url=url;
this.questionsP erPage=3;
this.currentPag e=0;
this.questions=[];
this.questionsX ML="";
document.questi onClass=this;
this.paper=new Object();
},
//get question query to server
getQuestions: function(params ){
ajax=new Ajax.Request(th is.url,
{
method: 'get',
parameters: params,
onComplete: this.paperLoade d
});
},
paperLoaded: function(xhr){
alert(xhr.respo nseText);
document.questi onClass.questio nsXML="";
document.questi onClass.questio nsXML=xhr.respo nseXML;
document.questi onClass.extract Questions();
document.questi onClass.showQue stions();
},
//convert xml of question to array
extractQuestion s: function(){
//extract paper properties
var par=this.questi onsXML.getEleme ntsByTagName('q uestions');
this.paper.leve l=par[0].getAttribute(' level');
this.paper.subj ect=par[0].getAttribute(' subject');
this.paper.year =par[0].getAttribute(' year');
this.paper.pape r=par[0].getAttribute(' paper');
alert(this.pape r.level);
//extract questions from xml cross browser purpose use get tag names
var ques=this.quest ionsXML.getElem entsByTagName(' 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[i].getAttribute(' name');
obj.questionId= ques[i].getAttribute(' questionId');
obj.question=qu es[i].firstChild.nod eValue;
this.questions[i]=obj;
}

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

May 15 '06 #1
1 1321
ma********@gmai l.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
3020
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' priviledged methods also. Do you know if this is possible ? In the following example, I create an ObjectA (variable a), an ObjectB which inherits...
4
2220
by: jemptymethod | last post by:
http://htmatters.net/htm/1/2006/01/EIBTI-for-Javascript-explicit-is-better-than-implicit.cfm
13
2543
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(){}, my_meth2: function(){} }); to define new methods on the MyObj prototype object. Object.extend
6
1477
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 creation of a class easier to read/understand. Anyway it seems to break the inheritance chain in the following code and I don't know why. ...
5
4179
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
1942
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 http://www.javascripttoolbox.com/bestpractices/#prototype) and am discovering that there is general distaste for prototype.js. In my first post to this group I...
6
1862
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" using the prototype property. I realize there are no classes in JS, that code therefore lives in objects instead of class definitions, and that...
2
2082
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: function A(){ var _this = this; this.a = 10;
2
6455
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 () { /* overwrite function definition */ } The above works fine for me even when someFunction is originally defined in a seperate frame other than...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.