Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Prototype AJAX Issues

Reply
Thread Tools

Prototype AJAX Issues

 
 
morganwhitney@gmail.com
Guest
Posts: n/a
 
      03-03-2006
Hi all, I am developing a web app and I am implementing the JavaScript
using the Prototype Framework. I have done all the same stuff from
scratch in a previous application and it worked fine, but I am having a
couple of issues when trying to use Prototype.

1. Parameters are not sent if I specify a transport method:

var url = baseurl+'lib/login.php';
var pars = 'login=' + $F('ad_login') + '&passwd=' + $F('passwd');
var myAjax = new Ajax.Request(
url, {
method: 'get',
parameters: pars,
onComplete: showResponse
}

If I specify either get or post for the method, the parameters do not
get since. I removed the line "method: 'get'," completely and then it
started sending the parameters via post. This is OK since I got it to
work, but it annoys me to no end.

2. ResponseText from AJAX call has extra white space.

my showResponse function that gets called by the onComplete returns the
text with a bunch of extra white space in it. It didn't do this in my
last application and it uses the same PHP script, so I know it is not
actually generating the white space in the response. Because of this,
my application cannot tell whether or not an attempt was successful
because the comparison does not work.

Any ideas?

 
Reply With Quote
 
 
 
 
morganwhitney@gmail.com
Guest
Posts: n/a
 
      03-07-2006
I managed to get the method: part working, but the whitespace issue
persists. I wrote a newline character stripper function and am wrapping
the responses in it before they are evaluated, which works, but it is
ugly:

function ajaxLogin() {
var url = baseurl+'lib/login.php';
//var url = "url/to/the/file//login.php";
var myAjax = new Ajax.Request(
url, {
method: 'post',
parameters: Form.serialize($("loginform")),
onComplete: showResponse
}
);
}

function showResponse(originalRequest) {
var response = originalRequest.responseText;
response = stripNewlines(response);

if (response == "success") {
window.location = "home.php";
} else {
$('loginmessage').innerHTML = response;
}
}

 
Reply With Quote
 
 
 
 
morganwhitney@gmail.com
Guest
Posts: n/a
 
      03-07-2006
Forgot to mention the Firebug thing. I use it, live it, love it.
Firebug is how I noticed the additional whitespace in the first place,
since when viewing it via the webpage you can't tell.

 
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
Issues with IE & Prototype/AJAX Steve-O Javascript 17 08-04-2006 05:36 AM
relation between prototype and Prototype.js shypen42@yahoo.fr Javascript 9 05-26-2006 01:13 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