Wednesday, May 28, 2014

jQuery AJAX - Purposefully POST no parameters using JSON contentType

My issue: Purposefully execute a .NET WebMethod via POST without passing it parameters.  I use $.ajaxSetup to configure my page's calls, so I'm assuming this is where my snag came up, but I didn't want to have to work around this and make my $.ajax() calls more verbose.

Simple answer: encode an empty JSON object, and it won't be passed to the WebMethod when contentType is JSON.


No comments:

Post a Comment