All,

[ I got called out of the office for about an hour and didn't get to
send this].

Oliver,

I'll remember that for the future. I have solved the problem.

Suspecting the formdata content was suspect I hardcoded a simple
request, e.g.,

formdata = 'foo=bar'; // no failure

Then I looked to see if the .serialize() command was the culprit. It
wasn't.
Then I looked at each of the values I was appending to formdata and
everything worked until appended last_update_by.

Doh!

The simple fix was to escape() all of the Collaborator.data variables.

        var formdata;
        formdata  = $("#collaborator_choice_mgmt").serialize();
        formdata += '&id='  + escape(Collaborator.data.id);
        formdata += '&version='  + escape(Collaborator.data.version);
        formdata += '&last_update_by=' +
escape(Collaborator.data.last_update_by);

I realized that the reason similar code hadn't failed in the past
was that I would often put the data that I now have in an object
into hidden form variables. As a result .serialize() would handle
the encoding for me. I've always used .serialize out of convenience.
Others have suggested other ways to do this with the bare .ajax( )
call and passing form data as on {object} instead of a parameter
string. I'll look into that for the future.

Thanks,

-- Brad


On 3/16/11 9:45 AM, [email protected] wrote:
> In this cases it did help me, to analyze the request with HttpFox.
> https://addons.mozilla.org/de/firefox/addon/httpfox/
>
> Regards, Oliver
>
> Am 16.03.2011 um 16:16 schrieb Brad Perkins:
>
>> On 3/16/11 9:10 AM, Brad Perkins wrote:
>>> This is more of a Javascript question, but I have used similar code
>>> when working with PHP backends and haven't had problems. Active4D is
>>> responding with a 400 Bad Request.
>>>
>>> I'm using the following JS function to submit a POST xmlHTTPRequest
>>> to Active4D. I've removed some code for illustration purposes, but
>>> have tested with code below and it fails too.
>>>
>>> I suspect that Active4D doesn't like how formdata is formatted. Here
>>> is an example formdata value that fails:
>>>
>>> |short_name_menu=NOAA&short_name=NOAA&full_name=National+Oceanic+and+Atmospheric+Administration&url=http||%3A%2F%2Fwww.noaa.gov&assoc_natl_lab_acronym=&id=1001&version=1&last_update_by=Brad
>>> Perkins|
>> For clarification, I copy/pasted the above from Firebug. Firebug
>> doesn't display the | characters that came across in this message.
>> When I paste the same code into various text editors I'm not seeing
>> those |'s as either literal or invisible characters.
>>
>> -- Brad
>>
>>
>> _______________________________________________
>> Active4D-dev mailing list
>> [email protected]
>> http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
>> Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/
> _______________________________________________
> Active4D-dev mailing list
> [email protected]
> http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
> Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/
>

_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to