You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to create POST request to specified action? #1021
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:
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: http://wisej.com/support/question/serving-static-content
See attached sample for the [WebMethod] approach. Look at the JavaScriptEvents attached to the buttons.
I have used the Wiget with WebRequest Event:
private void _ganttWidget_WebRequest(object sender, WebRequestEventArgs e)
{
e.Response.ContentType = “application/json”;
e.Response.Write(new { test = “text” });
}
And in the InitScript, I used the ajax to request:
$.ajax({
url: this.getPostbackUrl(),
method: ‘POST’,
data: null,
success:function(response){
console.log(response);
}
});
However, the ajax request is not working.
I also include Jquery Ajax library in the Widget packages.
Did I misunderstand something?
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
Activity
itg-assistant commentedon Jun 12, 2026
Luca answered 2017-08-16 15:12:05 UTC
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) { ... });
http://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: http://wisej.com/support/question/serving-static-content
See attached sample for the [WebMethod] approach. Look at the JavaScriptEvents attached to the buttons.
itg-assistant commentedon Jun 12, 2026
Truong Nguyen answered 2017-08-17 02:50:02 UTC
I have used the Wiget with WebRequest Event:
private void _ganttWidget_WebRequest(object sender, WebRequestEventArgs e)
{
e.Response.ContentType = “application/json”;
e.Response.Write(new { test = “text” });
}
And in the InitScript, I used the ajax to request:
$.ajax({
url: this.getPostbackUrl(),
method: ‘POST’,
data: null,
success:function(response){
console.log(response);
}
});
However, the ajax request is not working.
I also include Jquery Ajax library in the Widget packages.
Did I misunderstand something?
itg-assistant commentedon Jun 12, 2026
Luca answered 2017-08-17 16:29:35 UTC
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