Prototype AJAX Issues

Discussion in 'Javascript' started by, Mar 3, 2006.

  1. Guest

    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?
    , Mar 3, 2006
    1. Advertisements

  2. Guest

    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

    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;
    , Mar 7, 2006
    1. Advertisements

  3. Guest

    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.
    , Mar 7, 2006
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. June Lee
    Jim Cobban
    Apr 13, 2008
  2. Replies:
    Thomas 'PointedEars' Lahn
    May 26, 2006
  3. Steve-O

    Issues with IE & Prototype/AJAX

    Steve-O, Aug 2, 2006, in forum: Javascript
  4. Replies:
  5. javascript fish
    javascript fish
    Oct 11, 2008

Share This Page