Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
I wrote a javaScript which will call one of the JSON API web services when the user click on a button , so i wrote the following inside a custom HTML field on the Joget form builder, but nothing will be displayed when the user click on the button and only the #title will be changed.
<script language="JavaScript"> function test () { $.ajax({ url: "http://localhost:8080/jw/web/json/workflow/package/list", type: "GET", cache: false, success: function (result) { $('#products').empty(); $('#title').text("All Processes"); $.each(result.data, function (key, val) { var str = val.packageName; $('<li/>', { text: str }) .appendTo($('#products')); }); } }); }; </script> <form name="myForm"> <input type="button" value="Display alert box" name="button1" onClick="alert('You clicked the first button.')"><br> <input type="button" value="Call on button 1" name="button2" onClick="test()"> <h1 id ="title"></h1> <ul id="products"> </ul> </form>
Can anyone advice how can i make my code works well . baring in mind that i run my code inside a visual studio web project and the above code worked well and the list of packages which were returned from the APi call were displayed successfully.
Best Regards
4 Comments
Hugo
Hi BR,
You will need to add another parameter into your AJAX call to indicate that you are expecting a plain text response.
Try to run the following in your Firebug
Good luck!
BPMdesigner
Thanks for the reply. i tried
but still the javascript will not display the list of processes. but i have also these two questions:-
1. why i should define the dataType to be plain text, although the returned result from the call will be JSON?
2. i am calling a Get service ,, why i should defined type: "POST",
Thanks in advance for yuor help.
Best Regards
BPMdesigner
i changed thedata type to be
and the call worked fine.
Best Regards
Hugo
Hi there,
Glad it helps. Welcome.