I'm am very new to using JQuery and Ajax so what I am struggling with may be simple.
I have a laravel method that returns a JSON response. I am calling the method in AJAX which returns the data correctly as shown below
{"contribution_id":"72","name":"October 2133","at_total":"12","at_key_accounts":"12","at_targeted_accounts":"12","at_sundry_accounts":"12","at_new_business":"12","yd_total":"12","yd_key_accounts":"12","yd_targeted_accounts":"12","yd_sundry_accounts":"12","yd_new_business":"12","created_at":"2014-09-16 15:17:05","updated_at":"2014-09-16 15:17:05"}
In my view I am trying access each part of the data individually. I can alert all of the JSON but I am unable to just return one of the variables.
This is my AJAX code, it alerts "undefined"
<script>
var con_id = $("#con_id").val()
$.ajax({
url: "/tpquarterly/laravel/public/getContribution/" + con_id,
context: document.body
}).done(function(data2) {
alert(data2.contribution_id)
$( this ).addClass( "ere" );
});