0

I have a problem with my program as I want to access data from my website. The data is published by a REST server. I do get the data but it is not showing up. Here is an example of the JSON data:

{"Data":[{"Uid":1,"age":30,"cedula":54689,"lastName":"kumar","mail":"algo@ailfs","name":"Sam"},{"Uid":2,"age":35,"cedula":123589,"lastName":"kumar","mail":"lndsfkl@kjnnf","name":"Ram"},{"Uid":3,"age":39,"cedula":8453,"lastName":"Perez","mail":"sdbfk@kgmial","name":"Sam"},{"Uid":4,"age":56,"cedula":87956216,"lastName":"Perez","mail":"kav@gamil.com","name":"Pepe"},{"Uid":5,"age":72,"cedula":849666,"lastName":"Mujica","mail":"pepe@gmail.com","name":"Pepe"},{"Uid":6,"age":25,"cedula":10565896,"lastName":"Aughburn","mail":"jkd@gmail","name":"Rosh"}],"Page":1,"PageSize":6,"TotalPages":2}

and my jqgrid code:

jQuery("#jQGridDemo").jqGrid({
    url: myurl, 
    datatype: "jsonp",
    mtype: "GET",
    ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }, 
    jsonReader: {
        root: "Data",
        page: "Page",
        total: "TotalPages",
        records: "PageSize",
        repeatitems: true,
        cell: "",
        id: "0"
    },
    colNames: ['Id', 'Nombre', 'Apellido', 'Edad', 'Cedula',
             'Email'],
    colModel: [
    { name: 'Uid', index: 'Uid', width: 20 },
    { name: 'name', index: 'name', width: 150 },
    { name: 'lastName', index: 'lastName', width: 150 },
    { name: 'age', index: 'age', width: 120 },
    { name: 'cedula', index: 'cedula', width: 60 },
    { name: 'mail', index: 'mail', width: 200, sortable: false },
    ],
    rowNum: 5,
    rowList: [2, 5, 10],
    sortname: 'Id',
    loadonce: true,
    viewrecords: true,
    ignoreCase: true,
    sortorder: "desc",
    caption: "Usuarios del Sistema",
    loadError: function (xHr, status, error) { alert(error);}
}); 

I put the loadError function in and it says soething like "error: jQuery111045... was not called"

Thanx for any help.

darshanags
  • 2,519
  • 1
  • 13
  • 19
  • looks like your jQuery is looking for a jsonp response. `The jsonp type appends a query string parameter of callback=? to the URL. The server should prepend the JSON data with the callback name to form a valid JSONP response.` jQuery docs: http://api.jquery.com/jQuery.ajax/#data-types – darshanags Apr 17 '14 at 14:53
  • It could be that you need to use additional options, see [the answer](http://stackoverflow.com/a/15521572/315935) for example where `ajaxGridOptions: { jsonp: false, jsonpCallback: 'eqfeed_callback', cache: true}` was required. Is the URL of REST server public and you can include it in the text of your question? If not then you should use some HTTP tracing tool like [Figgler](http://www.telerik.com/fiddler) or Network tab of Developer Tools of IE or Google Crome (press F12 to start). You should append the text of your question with full response of the server including all HTTP headers. – Oleg Apr 17 '14 at 16:20

0 Answers0