PrototypeJS Library Problem

He has: 1,380 posts

Joined: Feb 2002

Hey everyone

I just started using Prototype ([url]http://www.prototypejs.org)[/url], and I'm having a problem...

I've been through the docs, and I've spent 2 hours on the prototype IRC channel with a guy trying to figure it out, and we have no idea...

this is what the form header looks like:

c_top = '<form id="popEdit" method="GET" action="http://www.myshoutoutloud.com/callback.php" onsubmit="sendData()"><table>';

(it's in the c_top variable because it gets used a bunch of times)

so... accoring to everything, that should work. And it does. Except that it actually sends you to that url with all of the variables attached as GET parameters... instead of doing it async in the background. (FireBug isn't any help on this...)

Anybody have ANY ideas? I'm willing to try about anything at this point.

I was using Ajax.Request, but this new form request is supposed to be better/easier (it's in the new version of Prototype)

Thanks, hopefully someone knows...

He has: 1,380 posts

Joined: Feb 2002

Ok, so it doesn't redirect the browser to the URL anymore, but it doesn't make the XML query either.

form header:c_top = '<form id="popEdit" method="GET" action="http://www.myshoutoutloud.com/callback/editData.php" onSubmit="sendData(); return false;"><table>';

sendData(e):

function sendData() {
$('popEdit').request({onSuccess: closeData()});
}
'

closeData():

function closeData() {
$('editData').style.display = 'none';
$('editData').innerHTML = '';
}
'

... any ideas?

He has: 1,380 posts

Joined: Feb 2002

Ok, so for anyone who cares...

Don't bother to use the IRC channel. Most of the people there either repeat what the docs say, or are ... "not nice".

I fixed the problem myself, but stumbled upon it. The way I fixed it is to use:
form header:
c_top = '<form id="popEdit" action="http://consumer.myshoutoutloud.com/index.php" onsubmit="sendData(); return false"><table>';

sendData:

$('popEdit').request({
method: 'get',
onComplete: closeData,
onFailure: function(){ alert('Something went wrong...')}
});
'

And then I created an if statement on that same page, looking for the $auth var... if it existed, include the callback page.

Not the way it was supposed to happen, but this works like a charm.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.