As the title, I want to create an ajax Post method to the server.
How can I create an action link for Ajax can post the data to that action.
Something like that:
$.ajax({
url: action_url,
method: ‘POST’,
data: {}
});
How can I create the “action_url” from the server?
Thank you.
See attached sample. Uses two different ajax requests, the first uses jquery, the second uses the built-in xhr object so you don’t need to download jquery: http://www.qooxdoo.org/5.1/api/#qx.io.request.Xhr
What do you need to do?
For a simple ajax request you can use any ajax library, like jQuery, or you can use the XMLHttpRequest class directly.
If you need to invoke an action on the server, with Wisej you can simply add a public static [WebMethod] method to Program.cs and then call it from javascript using App.{methodName}(args); You can even receive the return value like this:
App.{methodName(args, function(retVal) { … });
https://wisej.com/docs/html/JavaScriptObjectModel.htm
If you add a public non-static [WebMethod] to a top level control (Form or Page or Desktop) then you can call it from JavaScript directly on the object.
Another way is to implement the IWisejHandler interface on a class. Or you can use a Wisej.Web.Widget and handle the WebRequest event. In which case the URL is this.GetPostbackURL(). See this: https://wisej.com/support/question/serving-static-content
See attached sample for the [WebMethod] approach. Look at the JavaScriptEvents attached to the buttons.
Please login first to submit.