Call any webservice from the same $.ajax() call

Posted by Andreas on Stack Overflow See other posts from Stack Overflow or by Andreas
Published on 2010-04-28T14:09:23Z Indexed on 2010/04/28 14:13 UTC
Read the original article Hit count: 202

Filed under:
|
|
|

Hi!

Im creating a usercontrol which is controled client side, it has an javascript-file attatched to it. This control has a button and upon click a popup appears, this popup shows a list of my domain entities. My entities are fetched using a call to a webservice.

Im trying to get this popup usercontrol to work on all my entities, therefore i have the need to call any webservice needed (one per entity for example) with the same $.ajax() call.

I have hiddenfields for the webservice url in my usercontrol which you specify in the markup via a property. So far so good. The problem arise when i need some additional parameters to the webservice (other than pagesize and pageindex). Say for example that one webservice takes an additional parameter "Date".

At the moment i have my parameters set up like this:

    var params = JSON.stringify({
        pageSize: _this.pageSize,
        pageIndex: _this.pageIndex            
    });

and then i call the webservice like so:

$.ajax({
    webserviceUrl,
    params,
    function(result) { 
          //some logic
    });
});

What i want to do is to be able to add my extra parameters (Date) to "Param" when needed, the specification of these parameters will be done via properties of the usercontrol.

So, bottom line, i have a set of default parameters and want to dynamically add optional extra parameters.

How is this possible?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about usercontrols

Related posts about webservice