0

I have a cross domain request that requires the callback to be specified as follows

http://<server>:<port>/../../abc?_callback=<callbackName>

With jqGrid, I am not sure how to go about enabling this. jqGrid is a wrapper for the $.ajax call which takes in the url and also allows you to specify the crossdomain properties. My current configuration which provides the right response:

$("#list").jqGrid({
url:'<sample cross domain URL>',
callback: 'callme',
mtype: 'GET',
crossDomain: true,
datatype: 'jsonp',
jsonp: true,
cache: true,
....... // other grid properties to load the layout for this dynamic data. 

)};

The line "callback: 'callme'" does not seem to work as firebug shows a default callback value assigned for the request. However this callback is specified as

<sample URL>?callback=jqueryXXX...X 

instead of

<sampleURL>?_callback=callme

Is there any way in which jqGrid allows you to specify custom callback names?

Keshi
  • 906
  • 10
  • 23

2 Answers2

0

Your main error is that you use some options which not exist in jqGrid. You use callback, crossDomain, jsonp and cache which are supported options of jQuery.ajax, but there are no such options in jqGrid.

I hope that you find answer on your question after examining of demos from the answer and another one.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
0

I had also some problems with jqgrid and a remote URL (cross domain). To solve them, I have used a php page on my domain : cross-domain.php that takes a GET parameter :

Here is the content of the php page :

<?php
    print(file_get_contents($_GET['url']));
?>

Thus, to fill a jqgrid with such an URL :

jQuery("#jqgrid_table_id").jqGrid({
    url : <?php print("'cross-domaine.php?url=" . urlencode('http://www.example.com/my_json_webservice.php') . "'"); ?>,
    ...
});

It works great, and of course it can be done with any server language.

And you don't have to worry about same origin policy issues.

kmas
  • 6,401
  • 13
  • 40
  • 62