confusing error: [object DOMWindow] does not understand #keys

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

confusing error: [object DOMWindow] does not understand #keys

patmaddox
I'm trying to make an ajax request using jQuery's ajax function. It works fine as long as I don't pass in any data.  For example, the following call works:

purchase
        | emailAddress url data |
        emailAddress := (el find: 'input[name="purchase[email_address]"]') val.
        url := basePath , 'purchases.json'.
        data := #{ 'purchases_email_address' -> emailAddress }.
        console log: data.
        jQuery ajax: ( #{'type' -> 'POST' . 'success' -> [ :d | self success: d ] . 'url' -> url } ).


but if I try to pass in the data object, I get the error message listed in the subject

purchase
        | emailAddress url data |
        emailAddress := (el find: 'input[name="purchase[email_address]"]') val.
        url := chargeforitBasePath , 'purchases.json'.
        data := #{ 'purchases_email_address' -> emailAddress }.
        console log: data.
        jQuery ajax: ( #{'type' -> 'POST' . 'success' -> [ :d | self success: d ] . 'url' -> url . 'data' -> data } ).

yields

[object DOMWindow] does not understand #keys

I'm very very confused as to what's going on...I don't know why passing in 'data' -> data  causes it to think that DOMWindow is somehow the recipient of the keys message? I can't spot the bug. Is it a scope / binding issue? Am I misunderstanding how smalltalk associations turn into javascript objects?

Thanks for any help.

Pat