Wrox Programmer Forums
BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6
This is the forum to discuss the Wrox book Professional Ajax, 2nd Edition by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780470109496
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 26th, 2011, 09:47 AM
Registered User
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with function getRequestBody

function getRequestBody(oForm) {

//array to hold the params
var aParams = new Array();

//get your reference to the form
var oForm = document.forms[0];

//iterate over each element in the form
For (var i=0 ; i < oForm.elements.length; i++) {

//get reference to the field
var oField = oForm.elements[i];

//different behavior based on the type of field
switch (oField.type) {
case "text":
case "hidden":
case "password":
aParams.push(encodeNameAndValue(oField.name, oField.value));

Well the offending line is as follows

aParams.push(encodeNameAndValue(oField.name, oField.value))

do not recognize the oField.name...
to return the call the string does not contain the names of parameters, but only the values for example


missing name: user=daniele&psw=moon

Old February 26th, 2011, 12:12 PM
jmcpeak's Avatar
Wrox Author
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts

Can you provide your markup, please?
Old February 26th, 2011, 01:49 PM
Registered User
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Smile I solved

I solved .. I had not declared a "name" tag in the input using only "id". I modified the function this way:

if (oField.name!='')
aParams.push(encodeNameAndValue(oField.name, oField.value));
aParams.push(encodeNameAndValue(oField.id, oField.value));

many thanks

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem function lejka Java Basics 1 August 20th, 2009 02:53 AM
function problem lejka Java Basics 0 August 7th, 2009 02:31 AM
getRequestBody function vs checkbox Passero BOOK: Professional Ajax ISBN: 978-0-471-77778-6 2 May 29th, 2006 11:21 AM
Problem with function mat41 Classic ASP Basics 3 July 16th, 2005 01:19 AM
Problem with a Javascript function SuMajestad PHP How-To 4 August 17th, 2004 09:04 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.