1

I am using this function try to make a request to the server. I am wondering how could I get data sent by Jquery Ajax in Rails controller.

function addnote(){

    $.ajax({

        type: "POST",

        url:SERVER_URL+"api/addNotes/",

        data: {note_text: $('#note_text').val(), note_lat: $('#lat').val(), note_lng: $('#lng')},

        success: function(data, textStatus, jqXHR) {

        },
        error: function(jqXHR, textStatus, errorThrown) {
            alert("Error=" + errorThrown);
        }
    });

Here is my rails controller

def add_notes


    end

end

3
  • what's your routing? do you get errors? what's in SERVER_URL? what does firebug say when it reaches this line? Commented Jun 1, 2012 at 9:01
  • 2
    64 questions asked and ~50% accepted? don't you like people helping you since you show them no respect? Commented Jun 1, 2012 at 9:28
  • I like it bro, I only accepted when I receive my answers Commented Jun 1, 2012 at 9:30

2 Answers 2

4

In rails controller

def add_notes
    note_text = params[:note_text]
    note_lat = params[:note_lat]
    note_lng = params[:note_lng]
end
Sign up to request clarification or add additional context in comments.

Comments

0

You lost params[:note_add] -> you have only :note_text, :note_lat, :note_lng. Check your 'data:' string.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.