Welcome Guest, Not a member yet? Register   Sign In
Sending data via AJAX request
#1

[eluser]Unknown[/eluser]
Hello,
I'm unable to send data to controller via AJAX request. I have this code:
Code:
$.ajax({
                type: "POST",
                    url: "controller/method",
                    dataType: "html",
                    data: ({'key' : 'value'}),
                    success: function( data ) {
                        alert( data );
                    }
                });

Ajax response handler throws error code 500 and no data are returned.
It works fine when making request without additional data (parameter data).

Any idea?

Thank you.
#2

[eluser]JHackamack[/eluser]
I believe that JQuery's data should be:
For when you want to use a GET variable:
Code:
data: "name/John/location/Boston",
for post:
Code:
type: "POST",
      data: ({id : this.getAttribute('id')}),
you have to define the type as post, which I don't see.
#3

[eluser]Unknown[/eluser]
Solved: csrf protection must be disabled Smile




Theme © iAndrew 2016 - Forum software by © MyBB