473,698 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prototype AJAX Issues

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 '06 #1
3 1671
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***********@g mail.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?

Mar 4 '06 #2
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(or iginalRequest) {
var response = originalRequest .responseText;
response = stripNewlines(r esponse);

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

Mar 7 '06 #3
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 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4653
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 trying to send input from a form to do a live php boolean search. so an example search string is
11
1520
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 correctly). For example, when I do this, I use the keyword (?) "prototype": function Example() {
5
20071
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 with Firefox,but with IE6 the onFailure never gets called and the request never completes. My code: var ajaxReq = new Ajax.Request( url, {method: 'post', parameters:
31
3136
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 around here? If so, do you know if Ajax.NET can be used without prototype.js? -- "The most convoluted explanation that fits all of the made-up facts is the most likely to be believed by conspiracy theorists. Fitting the
17
3151
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 security settings are not an issue. Anyone have any insight on this? Thanks! -sh
5
4185
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.
23
1760
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 protorype.js should be splitted into small pieces of the js scripts with groupped functionality
4
7704
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 Ajax.Request( url, {method: 'post', parameters: params, onComplete: evalInfo }); function evalInfo( request ) { // do stuff with request
3
3579
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: Ajax.Base = function() {}; Ajax.Base.prototype = { setOptions: function(options) { <...>
0
9028
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.