Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > prototype problem

Reply
Thread Tools

prototype problem

 
 
mambenanje@gmail.com
Guest
Posts: n/a
 
      05-15-2006
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

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-22-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prototype WTP 0.2 released,this release for Prototype 1.6.0 javascript fish Javascript 0 10-11-2008 07:35 AM
Class prototype vs C function prototype June Lee C++ 2 04-13-2008 08:17 PM
Prototype Object.extend(new Base() | Hash | Hash.prototype) usage: jacobstr@gmail.com Javascript 3 03-27-2007 07:56 AM
relation between prototype and Prototype.js shypen42@yahoo.fr Javascript 9 05-26-2006 01:13 AM
Date prototype problem Christopher Benson-Manica Javascript 7 06-26-2005 09:03 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57