jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Webservice load with parameters from grid
This topic contains 2 replies, has 2 voices, and was last updated by hf 12 years, 1 month ago.
-
Author
-
Hi,
When I try accessing a webservice with json parameters the webservice won’t even fire. When I remove the data with parameters webservice will fire.
var parameters = “{‘datum’:'” + datumUS + “‘,’user_id’:'” + user_id + “‘}”;
var source = {
type: ‘GET’,
contentType: ‘application/json; charset=utf-8’,
datatype: ‘json’,
datafields: [
{ name: ‘id’, type: ‘int’ },
{ name: ‘g_name’, type: ‘string’ },
{ name: ‘g_id’, type: ‘int’ },
{ name: ‘date1’, type: ‘date’ }
],
url: ‘WebService1.asmx/getICG’,
data: parameters,
cache: true,
root: ”,
};var dataAdapter = new $.jqx.dataAdapter(source, { contentType: ‘application/json; charset=utf-8’,
downloadComplete: function (data, textStatus, jqXHR) {
if (data.d.indexOf(‘||_ERROR_||’) == -1) {
return data.d;
}
else{
errorHandler(‘getICG: ‘ + data.d.replace(“||_ERROR_||”, “”));
};
}
});When I access the webservice by ajax with parameters it will run also, but I would like to load it from out of jqxgrid, because of the loading image is visible then.
AJAX:
$.ajax({
type: “POST”,
url: “Webservice1.asmx/getDagstaatregels”,
data: parameters,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
success: function Succes(data, status) {
arrTest = data.d;
};Hi hf,
The problem could be that the Grid will try to send its own parameters along with yours. You may do the following:
Define a formatData callback in the jqxDataAdapter’s initialization. The formatData callback function which is called before the data is sent to the server. You can use it to fully override the data sent to the server. If you define a ‘formatData’ function, the result that the function returns will be sent to the server i.e the result will be passed to the jQuery’s Ajax function.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Thank you pointing me in the right direction!
All I had to do was adding this to the source:
formatdata: function (data) {
return { test: “‘Hello World!'” }
} -
AuthorPosts
You must be logged in to reply to this topic.