DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

API

Sort:
You are not authorized to post a reply.





New Around Here





    Hi I am new on DNN. I have a api called. https://www.abc.com/getdata/1 and Inside of desktopmodule I have a simple ascx written asp.net and I want to create jquery ajax to call the API - https://www.abc.com/getdata/1

    What do I need to do making it works in a simple DNN module?

    Below is the js codes that I currently use for another HTML project. I hope I can copy over to DNN module

    <script type="text/javascript">
        function GetProductList() {
            var tr='';
            var model = { 'Manufacturer_ID': 852 };
            $.ajax({
                type: "POST",
                url: "https://www.whatever.com/...ist?type=json",
                dataType: "json",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(model),
                success: function (data) {
                    //alert("HI");
                    $.each(data, function (index) {
                        tr = tr + data[index].Product_ID + ":" +  data[index].ProductName + '\n';
                    });
                    alert(tr);
                },
                error: function (error) {
                    alert("Error " + error);
                }
            });
        }
    </script>






    Growing Member





      Hi Ricky,

      If your API (e.g. your .ashx file) is located within your module you need to target the full path, e.g. if your module is called MyModule the path would be https://www.abc.com/Deskt...le/MyApiHandler.ashx - created dynamically so the module will work in more than one site ;-)

      If the API you are calling is external the current code seems to be ok, although you may want to include cache: false in the properties - and perhaps a boolean in the result to indicate success or serverside error.

      #DnnBro
      You are not authorized to post a reply.

      These Forums are dedicated to the discussion of DNN Platform.

      For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

      1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
      2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
      3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
      4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
      5. No Flaming or Trolling.
      6. No Profanity, Racism, or Prejudice.
      7. Site Moderators have the final word on approving / removing a thread or post or comment.
      8. English language posting only, please.

      Would you like to help us?

      Awesome! Simply post in the forums using the link below and we'll get you started.

      Get Involved