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? 3 1644
Hi,
Well i am not sure if you just didn't copy and paste correctly here, but
you haven't closed your object correctly, you need a ');'
aside from that, all looks good, have you used the the 'FireBug' extension
for firefox? it will let you see your ajax calls and responses.
chuck mo***********@gmail.com wrote: 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?
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;
}
}
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: chuck |
last post by:
Hi,
Firstly, I don't know if this is just and isolated thing with the
prototype.js library or
is a problem in general with ajax calls with a '+' character, so i am
posting it here.
I am...
|
by: shypen42 |
last post by:
Hi all,
I'm very confused by the relation between "prototype" and
that "Prototype.js" library that seems to be used quite a lot
(not by knowledgeable people from this group if I understood...
|
by: dougwig |
last post by:
I'm trying to handle the scenario where a user's session times out and
and their ajax request triggers a redirection by the webserver (302
error?).
I'm using Prototype 1.4 and the my works great...
|
by: Tony |
last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET
distribution - I'm pretty concerned about this. Does anyone know if this
is the same "prototype.js" that is not well-liked...
|
by: Steve-O |
last post by:
The following code works great in FireFox, Opera, Netscape, Safari, and
Gecko, but NOT IE. Why?
I tried using 'native' js with setInterval and setTimeout, but I get
the same result. My IE...
|
by: Gerry Vandermaesen |
last post by:
Hi,
Does anyone have a freely available JavaScript JSON stringifier. So far
my search has been in vain, the one offered on
http://www.json.org/json.js does not seem to work for me.
|
by: Dautkhanov |
last post by:
Hello !
Does anybody have cutted version of prototype.js with
the AJAX functionality only?
I am a new in prototype.js topic, so I think this task
should be done by other developers.
Maybe...
|
by: ext237 |
last post by:
Simple ajax call seems to have some issues in Firefox. The "onComplete:" is
called BEFORE the response is returned by the call. Is there a coding issue
or a work around?
var ajax = new...
|
by: jacobstr |
last post by:
I've noticed Object.extend used in a few different ways and I'm having
trouble distinguishing why certain usages apply to a given situation.
On line 804 Ajax.Base is defined as follows:
...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |