Forum: Rails Spinoffs (closed, excessive spam) $H(object).toQueryString is not a function

Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-10 18:39
(Received via mailing list)
I have posted this before and have not been able to find an answer. I
have also posted this on the LinkedIn site with an answer directing me
to a change that is the same as the version of prototype.js that I am
currently using.

Hopefully, someone can direct me to another answer:  I have tried many
different forms of the 'parameters' property as can be seen. Here is
the code and Firebug error:

function chkLUlist(obj,refnum,deptid) {
 var nCustId  = $('form1').nCustId.value;
 var nTypeId  = $('form1').nTypeId.value;
 var cTextVal = obj.value;
 if (isEmpty(deptid)) { nDeptId = "" } else { nDeptId = deptid };
  var nRefNum  = refnum;
  //var strSubmit = 'nCustId='+nCustId+'&nTypeId='+nTypeId
+'&cTextVal='+cTextVal+'&nDeptId='+nDeptId+'&nRefNum='+nRefNum
  //var strSubmit =
$H({nCustId:nCustId,nTypeId:nTypeId,cTextVal:cTextVal,nDeptId:nDeptId,nRefNum:nRefNum});
  //var strSubmit = '?
nCustId='+'nCustId'+'&nTypeId='+'nTypeId'+'&cTextVal='+'cTextVal'+'&nDeptId='+'nDeptId'+'&nRefNum='+'nRefNum';
  //var strSubmit =
'nCustId='+'nCustId'+'&nTypeId='+'nTypeId'+'&cTextVal='+'cTextVal'+'&nDeptId='+'nDeptId'+'&nRefNum='+'nRefNum';
  //var strSubmit = 'nCustId='+nCustId+'nTypeId='+nTypeId
+'cTextVal='+cTextVal+'nDeptId='+nDeptId+'nRefNum='+nRefNum;  var url
= 'lookuplist.asp';
  //var strSubmit = 'nCustId='+encodeURI(nCustId)
+'nTypeId='+encodeURI(nTypeId)+'cTextVal='+encodeURI(cTextVal)
+'nDeptId='+encodeURI(nDeptId)+'nRefNum='+encodeURI(nRefNum);
  var strSubmit = {nCustId: nCustId, nTypeId: nTypeId, cTextVal:
cTextVal, nDeptId: nDeptId, nRefNum: nRefNum};
  var url = 'lookuplist.asp';
  new Ajax.Request(
   url,
   {
    method:     'post',
  parameters: strSubmit,
    onSuccess:  showResponse
   });
}

Firebug error display:

$H(object).toQueryString is not a function
toQueryString(Object nCustId=1 nTypeId=35 cTextVal=a nDeptId=6
nRefNum=4)prototype.js (line 144)
request("lookuplist.asp")prototype.js (line 1201)
initialize(function(), "lookuplist.asp", Object
method=post)prototype.js (line 1185)
wrap()prototype.js (line 238)
klass()prototype.js (line 48)
chkLUlist(input#REF4rowid1.labels a, 4, "6")common.js (line 147)
onblur(blur )action.asp (line 1)
[Break on this error] return $H(object).toQueryString();
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-10 18:45
(Received via mailing list)
Instead of parameters, try postBody: $H({ ... }).toQueryString()

-Fred

On Tue, Jun 10, 2008 at 11:38 AM, few1938 <few1938@gmail.com> wrote:

> function chkLUlist(obj,refnum,deptid) {
>  //var strSubmit = '?
> +'nDeptId='+encodeURI(nDeptId)+'nRefNum='+encodeURI(nRefNum);
> }
> klass()prototype.js (line 48)
> chkLUlist(input#REF4rowid1.labels a, 4, "6")common.js (line 147)
> onblur(blur )action.asp (line 1)
> [Break on this error] return $H(object).toQueryString();
>
>
> >
>


--
Science answers questions; philosophy questions answers.
Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-10 18:57
(Received via mailing list)
Still no joy. Here is the Firebug error:

$H({nCustId:nCustId, nTypeId:nTypeId, cTextVal:cTextVal,
nDeptId:nDeptId, nRefNum:nRefNum}).toQueryString is not a function
chkLUlist(input#REF4rowid1.labels ss, 4, "")common.js (line 146)
onblur(blur )action.asp (line 1)
[Break on this error] postBody:
$H({nCustId:nCustId,nTypeId:nTypeId,cTextVal:cTextVal,nDeptId:nDeptId...
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-10 19:02
(Received via mailing list)
Can you crack open your prototype.js and tell us what version you have?

Other Proto-heads, was $H({}).toQueryString introduced in 1.6?

On Tue, Jun 10, 2008 at 11:57 AM, few1938 <few1938@gmail.com> wrote:

> On Jun 10, 12:45 pm, "Frederick Polgardy" <f...@polgardy.com> wrote:
> > > to a change that is the same as the version of prototype.js that I am
> > >  if (isEmpty(deptid)) { nDeptId = "" } else { nDeptId = deptid };
> 
nCustId='+'nCustId'+'&nTypeId='+'nTypeId'+'&cTextVal='+'cTextVal'+'&nDeptId='+'nDeptId'+'&nRefNum='+'nRefNum';
> > >  var strSubmit = {nCustId: nCustId, nTypeId: nTypeId, cTextVal:
> >
> > > chkLUlist(input#REF4rowid1.labels a, 4, "6")common.js (line 147)
> > > onblur(blur )action.asp (line 1)
> > > [Break on this error] return $H(object).toQueryString();
> >
> > --
> > Science answers questions; philosophy questions answers.
> >
>


--
Science answers questions; philosophy questions answers.
Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-10 19:05
(Received via mailing list)
My copy of prototype.js is:

/*  Prototype JavaScript framework, version 1.6.0.2
 *  (c) 2005-2008 Sam Stephenson
 *
 *  Prototype is freely distributable under the terms of an MIT-style
license.
 *  For details, see the Prototype web site: http://www.prototypejs.org/
 *

*--------------------------------------------------------------------------
*/
dated 2/18/2008. Date maybe incorrect, I have opened it with an
editor. Don't think the touch time has changed.
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-10 19:10
(Received via mailing list)
I just typed $H({a:1, b:2, c:3}).toQueryString() into the Firebug
console
and got 'a=1&b=2&c=3' so it definitely works in 1.6.0.2.  There's
something
weird we're not seeing.  Are you absolutely positive the path to
prototype.js in your script tag is correct?  And there's no possible way
$H
is being redefined?

On Tue, Jun 10, 2008 at 12:05 PM, few1938 <few1938@gmail.com> wrote:

> > > Still no joy. Here is the Firebug error:
> > > > Instead of parameters, try postBody: $H({ ... }).toQueryString()
> am
> > > > >  var nTypeId  = $('form1').nTypeId.value;
> >
> > > > >  //var strSubmit = 'nCustId='+encodeURI(nCustId)
> > > > >    onSuccess:  showResponse
> > > > > method=post)prototype.js (line 1185)
> > Science answers questions; philosophy questions answers.
> >
>


--
Science answers questions; philosophy questions answers.
Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-10 19:16
(Received via mailing list)
The web page, the .asp file and prototype.js are all in the same
folder.  I cut and pasted your test into my firebug command window and
got this:

TypeError: $H({a:1, b:2, c:3}).toQueryString is not a function
Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-10 19:33
(Received via mailing list)
Here is the description of 'TypeError'
A TypeError is thrown when an operand or argument passed to a function
is incompatible with the type expected by that operator or function.
Don't know if that will help?
Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-10 20:13
(Received via mailing list)
Don't know why, but I moved the call for the prototype.js file to the
end of the <head> tag and the call to .toQueryString() works.

Fred, Thanks for your help...

Frank
This topic is locked and can not be replied to.