0

Hi, I have a javascript object which is converted from json to java script object. i want to display its values like after each key value pair, i want to insert new line. but i dont know exactly how to do that. below is my code, please take a look and tell me how i should insert a new line. i tried but its not inserting a new line is diplay.

$.ajaxSetup({ 
    cache: false 
    //timeout: 1000000 
}); 
 
//String.prototype.toJSON; 
 
//var the_object = {}; 
 
//function concatObject(obj) { 
//    str = ''; 
//    for (prop in obj) { 
//        str += prop + " value :" + obj[prop] + "\n"; 
//    } 
//    return (str); 
//} 
 
function concatObject(obj) { 
    strArray = []; //new Array 
    for (prop in obj) { 
        strArray.push(prop + ":\t" + obj[prop]+"*******************************************************\"\n\""); 
    } 
    return strArray.join(); 
} 
 
//var input = "stephen.gilroy1"; 
 
function testCAll() { 
    //var input = $('#Eid').val(); 
    //var input = $document.getElementById('Eid').getValue(); 
    //var input = $('input[name=Employee_NTID]').val(); 
    var keyvalue = { 
    //ntid: $('#Eid').val() 
        ntid:"ambreen.haris", 
        name:"ambreen" 
    }; 
    $.ajax({ 
        type: "POST", 
        url: "Testing.aspx/SendMessage", 
        data: "{}", 
        //data: "{'ntid':'stephen.gilroy1'}",       //working 
        //data: {'ntid': $('#Eid').val()}, 
        //data: {keyvalue}, 
        //data: { ntid: $('#Eid').val() }, 
        //data: ({ 'ntid': $('input[name=Employee_NTID]').val() }), 
        contentType: "application/json; charset=utf-8", 
        dataType: "json", 
        success: function(result) { 
            alert(result.d); 
            resultData = eval("(" + result.d + ")"); 
            $("#rawResponse").html(concatObject(resultData)); 
            //$("#response").html(resultData.sn); 
        }, 
        error: function(result) { 
            alert("jQuery Error:" + result.statusText); 
        } 
    }); 
}
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by amby
0

i have solved it by putting <br /> instead of "\n" in concatObject method like this: return strArray.join("<br />");

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.