Converting my GET to jQuery style

Converting my GET to jQuery style

Greetings All !

I'm just getting started using jQuery, having had a brief class on it last week.  The class focused mostly on the broad variety of things you can do with jQuery, so Ajax was only part of that and didn't get a whole lot of time and attention.

I am trying to take some Javascript I wrote a few weeks back.... complete with the old "createXMLHttp" routine and then a lengthy function with xhr.onreadystatechange .... and convert that over to jQuery.

The GET string I'm wanting to send has two parameters:    "action=fetchlog&incident_id=" + incident_id

I'm having problems figuring out how to pass those parameters to the "data" parameter for getJSON.  I did see an example online where somebody just tacked the parameters onto the end of the "url" parameter and it worked, but I'd rather learn how to do it the way it was intended.

I tried the following... "hard-coding" the incident_id, just to see if I could get it to work.:

function FetchLog2(incident_id){

  $.getJSON({
    url: "ajax_fetcher.php",
    data: { action:"fetchlog", incident_id: "26205"},
    dataType: "json",
    success: function(result){
      console.log("Success");
      //Parse_JSON_object_into_Log_Div(data);
    }
  });
}

(For now, I commented out the callback function... which is a function I'd already written elsewhere in the code / javascript file.    I'm hoping it's okay to hand-off to a pre-existing function like that?)

Anyways, Chrome's console keeps erroring on the GET with a 404 (Not Found).    What's odd is, the URL it is showing me does not show the page name or parameters we are calling.  Instead, it's showing, "[object%20object]".      Now, I thought it was supposed to convert that "data" object into a string and tack it onto the end of the URL as the query string??    Odd that it isn't even mentioning the file / page that it's calling either.

What am I doing wrong here?


Thanks!

-= Dave =-