Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Ajax POST Request sending data issue
    primarykey
    data
    text
    <p>I have searched a lot and not been able to find a working solution to why my post request is not sending it's data to the server. I can send the request without data and I get my results from the server, but I just cannot send my data to the server. I have narrowed it down to the "data" attribute and assume I am just doing something wrong. Thank you.</p> <p><strong>Client</strong></p> <pre><code>var scriptURL = "default/scripts/serverside/Scripts.aspx"; $.ajax({ type: "POST", url: baseURL + scriptURL + "/SaveItem", data: "{}", //works (to return a result) //data: "{sendData: '" + dataPackage + "'}", //does not work //data: dataPackage, //does not work //data: { sendData: dataPackage }, //does not work //data: { "sendData": dataPackage }, //does not work contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { de("server result:" +result); } }); </code></pre> <p><strong>Server</strong></p> <pre><code>[WebMethod] public static string SaveItem(string sendData) { string result = "received: " + sendData; return result; } </code></pre> <p>Please help, I just cant seem to get it working and know it has got to be a syntax issue...</p> <p>Similar problems I have found (but no working answers):</p> <ul> <li><a href="https://stackoverflow.com/questions/7262940/webmethod-not-being-called?lq=1">https://stackoverflow.com/questions/7258933/jquery-ajax-data-parameter-syntax</a></li> <li><a href="https://stackoverflow.com/questions/7258933/jquery-ajax-data-parameter-syntax">https://stackoverflow.com/questions/7262940/webmethod-not-being-called?lq=1</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload