I think the main issue is that you're trying to send a JSON object, not a
JSON string. You can't send objects via HTTP, you have to stringify the
object.
$.ajax({
type: 'POST',
url: '/',
data: JSON.stringify({ 'formdata': 'abc' }),
}).done(function(data){console.log(data)});
On Sun, Sep 4, 2016 at 7:31 AM, Alex Povolotsky <[email protected]> wrote:
> Hello
>
> I'm trying fairly simple code
>
> $.ajax({
> type: 'POST',
> url: fd_url,
> dataType: 'json',
> data: { 'formdata': config },
> accepts: { 'json': 'application/json' }
> }).done(
> function ( data ) {
> alert(data.status);
> }
> );
>
> POST goes ok, but no parameter can be seen!
>
> All I have is an asset in request.
>
> Tried both $self->param( 'formdata' ) and $self->req->json, tried
> different Content-Type.
>
> What am I doing wrong?
>
> config is an object, I'm expecting to store it in database as json...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.