Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
February 19, 2008, 5:21 pm
rate this thread
I am using prototype.js to save data into MySQL using Ajax.Request
So i am grabbing the id and if the id<0 , I am adding it as a new
data, otherwise I am just updating it. Similarly I am checking if the
id>0, and then delete that row.
I have been able to add new data successfully but update and delete
function are just not working. When I look into the value of the
`id` , it displays as "undefined". Could anyone please tell me how to
proceed. The rest of the parameters are getting grabbed.
When I said provide the code that doesn't work I meant to only provide
the code that doesn't work -- not all the code that may or may not
work. Include the /smallest piece of code that illustrates the
problem you're having./ While doing that there's a good chance you'll
find the problem yourself.
Your problem seems more likely to be on the client side, based on your
but they'll probably bite your head off for using prototype.js in the
You need to somehow determine if 'id' is being passed into the query
string properly. Then you can determine if the problem is server-side
then I would have to point you to the client side.
unlikely to help you track this down.
Looking at the code you have sent, this line looks a bit odd - should
note really be in single quotes :-
var note = new PhotoNote(annotations[n].text,'note'.ID, box);
Also, ID is probably case-sensative, so make it lowercase. You may
then find it can be read by the SaveNoteDB() script.
Downer On Prototype?
** they'll probably bite your head off for using prototype.js **
Tony, I'm intrigued to know why people have such a downer on Prototype
- this isn't the first time I've read comments like this.
Whenever I've used it, I've found it to just simply do exactly what I
want, no bugs, no hacking through code, and superbly documented.
Hace you found problems in the past, or is it the purist in you?
Re: Downer On Prototype?
A bit of each. You can find good discussions about it:
One of my big problems is actually something that most people like: $().
I have a pretty big distaste for a library that encourages bad coding,
and $() tends to do that. Let's say, for example, that you want to
change three attributes on an element - with prototype, it is very easy
$('somediv').style.display = "block";
$('somediv').style.backgroundColor = "white";
$('somediv').style.color = "black";
The problem is that although this is much easier to type than using
document.getElementById('somediv'), it is significantly more inefficient
in execution, because $() simply calls document.getElementById(). Also,
if someone else were to look at the code, someone not familiar with
prototype.js, $() doesn't really tell him what's going on. A more
efficient, and clearer way to do the same thing would be:
var div = document.getElementById('somediv');
div.style.display = "block";
div.style.backgroundColor = "white";
div.style.color = "black";
Obviously, this COULD be done using $() - but that would be even more
difficult for the unfamiliar user to figure out, without searching for
the definition of $().
Also, the library is, in my opinion, not very well written, and
difficult to work with if you need to get into the guts of it - but I'll
concede that it's significantly better on that count than dojo :)
more like a class-based OO language rather than the prototype-based OO
language that it is - presumably so that its users don't have to learn
to even more bad code being put out there.
I would bet that a PHP library that did the same thing would be met by a
similar response here...