简体   繁体   中英

Handling the data portion of a jQuery AJAX call to WCF REST service

Fairly new to jQuery, I have a .ajax call going to a WCF RESTful service and my Uri template on the operation contract is the following:

UriTemplate = "/{appName}/{custCode}/{custUserName}/counter"

My problem is, I have a what is either going to be XML or JSON that I want to save to a database via the service and I'm confused how to get the service to receive the payload without having it as a variable in the Url.

My AJAX call looks like this so far:

$.ajax({
   type: "POST",
   url: ‘{../{appName}/{custCode}/{custUserName}/counter}’
});

Any help would be appreciated.

If I'm reading your question correctly, I think that you're asking how to send data to that server via ajax.

What you need to do is specify what the data is and add it to the 'data' setting in your ajax request.

So

var myData = "whatever your data is";
$.ajax({
    type="POST",
    url: ‘{../{appName}/{custCode}/{custUserName}/counter}’,
    data: myData
 })

You can also specify what to do with the response you get, perhaps letting the user know his/her data was saved or some such. http://api.jquery.com/jQuery.ajax/ is the list of all settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM