Wednesday 10 December 2008

App Server Log Reports [object HTMLInputElement] Instead of Text

Ran into this last week, chalk up another bone headed mistake for Mike. :) Once again, I'm hoping this note will help someone else if they run across this problem.


Problem: I'm using dojo.xhrPost to submit a form to an application server. However, when the data shows up on the application server, instead of text, I am getting [object HTMLInputElement]. Perplexing. If I submit the form without Dojo I seem to get text. What's the deal?


Solution: I was updating someone else's code to use a form for submission. The long and the short of it was, the old code uses "content:" to submit the data. The content attribute is used for creating an object literal list of values to submit data. For example:



myVar = {
param1:"some value",
param2:"another value"
}

Fine and dandy when you are using something other than a form.



...
content:myVar,
...

So I had changed the code to this, not noticing the slight change in syntax.



...
content:myForm,
...


However, since a form does not submit its data in this way, mayhem ensues. lol. To fix the problem, replace the above with:



form:myForm,


This results in happiness and joy for all.

No comments:

Post a Comment