Ajax response how to access

newbie

I got this response from ajax

{
  "laborCostIndex":0.0,
  "laborDailyWage":0.0,
  "laborHourlyWage":0.0,
  "laborMonthlyWage":0.0,
  "laborLeave":0.0,
  "laborBonus":0.0,
  "laborSSS":0.0,
  "laborPagIbig":0.0,
  "laborPhilHealth":0.0,
  "laborEMP":0.0,
  "laborTotalMonthlyRate":110.0,
  "laborTotalDailyRate":4.230769230769231,
  "laborTotalHourlyRate":0.5288461538461539
}

I'm trying to access the element inside through this:

response.laborCostIndex and response['laborCostIndex'] but seems doesn't work for me.

The ajax is from the xeditable here is the code:

UPDATE: posted the whole ajax

$('.laborCostIndex').editable({
    pk: '1',
    name: 'laborCostIndex',
    url: '../BTool/edit_laborCostIndex.do',
    validate: function( value ) {
        if($.trim( value ) == '') {
            return 'This field is required';
        } else if( isNaN( value ) ) {
                return 'Only accepts numbers';
        }
    },
    params: function(params) {
        var basicDailyWage = $(this).closest('td').next('td').find('a').text();
        var pagIbig = $(this).closest('tr').find(':nth-child(11)').find('a').text();
        var emp = $(this).closest('tr').find(':nth-child(13)').find('a').text();
        var datas = new Array(basicDailyWage, pagIbig, emp);

        params.pk = datas;
        return params;
    }, 
    success: function(response, newValue) {
        console.log( response );
        console.log( response.laborCostIndex );
        console.log( response['laborCostIndex'] );
    } 
});

Both results to undefined, I don't know why.

Senad Uka

Try this in your success function

 var obj = JSON.parse(response);
 console.log( obj.laborCostIndex);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to access AJAX response variables in PHP

From Dev

How to access this these two array in $.ajax response?

From Dev

How to access the value of a json array in AJAX response

From Dev

How to access ajax response data as html with javascript or jquery?

From Dev

How to access custom Java object sent as response in AJAX request, in JavaScript?

From Dev

How to access members of associative array from AJAX Response

From Dev

How to alert ajax response

From Dev

How to clear ajax response

From Dev

How to access Response in ApiController

From Dev

How to access Response in ApiController

From Dev

access elements of an ajax response comes as a stirng of array

From Dev

Access Ajax Call response PHP via jqXhr

From Dev

Cannot access or print Ajax response in jquery

From Dev

Access List of json object in ajax response

From Dev

jQuery - access multidimesional array from ajax response

From Dev

Access Ajax Call response PHP via jqXhr

From Dev

Cannot access or print Ajax response in jquery

From Dev

Unable to access AJAX Response Data through jQuery

From Dev

Polymer Iron Ajax - How to access Response from Request after Error Event?

From Dev

jQuery Ajax response 200, but cannot access the response data

From Dev

how to get $.ajax settings in response?

From Dev

How to get Ajax response in Go

From Dev

How to read AJAX response variable?

From Dev

Django template - ajax response - how to?

From Dev

How to handle Ajax JSON response?

From Dev

How to catch ajax error response?

From Dev

how to manage ajax response errors

From Dev

How to use the response of Ajax Post

From Dev

how to get $.ajax settings in response?

Related Related

HotTag

Archive