Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCan't seem to get a simple Ajax call to workCan't seem to get a simple Ajax call to work
Previous
 
Next
New Post
6/15/2017 12:53 AM
 

Hello,

Going through some growing pains porting my ASP.Net MVC over to DNN.

I've created a DAL2 MVC module from Chris Hammond's template.  Added in and tested a small JavaScript file.  Next step is to get Ajax working and then plug in the data layer from a DNN 6 module I already have and just start using it.  Simple process and I'm embarrassed that in this environment, making that 'easy' Ajax call isn't panning out.

I can call the checkbox and other items on the page and manipulate them, so that's working.  I can go to Edit | Settings, set a break point, hit a break point in the SettingsController.cs file.  I can do the same for ItemController.

I get a 404 when trying a simple Ajax call.  Somehow it's a routing or a URL error but I'm missing it.  On regular ASP.Net, what I'm doing with Ajax works.  With DNN I'm hitting speed bumps all over the place.

Appreciate any help, if there's anything I've not provided, let me know and I'll upload it.

Here is the ASCX file setting up the javascript registration:

<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="TestForm2.ascx.cs" Inherits="Durthaler.Modules.FirstDALMVC.TestForm2" %>

<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>

<dnn:DnnJsInclude runat="server" FilePath="/DesktopModules/MVC/FirstDALMVC/resources/javascript/settings.js" />


Here's my JavaScript

// JavaScript source code

$(function () {

$.ajax({

url: 'Item/Test' (have varied the url, using the full path, etc.  all I ever get is the error alert  below, never do hit success)

, type: 'POST'

, cache: false

//, data: {

// 'testData': 10

//}

//, dataType: 'json'

, success: function (data) {

got to success');

},

error: function (request, error) {

ein, Tod'); <-- Only getting here, never to success.

}

});

});

ItemController.cs file

namespace Durthaler.Modules.FirstDALMVC.Controllers

{

[DnnHandleError]

public class ItemController : DnnController

{

[HttpPost]

public ActionResult Test()

{

return null;

}

public ActionResult Delete(int itemId)

{

ItemManager.Instance.DeleteItem(itemId, ModuleContext.ModuleId);

return RedirectToDefaultRoute();

}

 

 
New Post
6/15/2017 5:15 PM
 
Have you looked at the MVC sample at https://github.com/dnnsoftware/Dnn.Pl... ?

Amarjit Dhunna Dnn Corp.
 
New Post
6/15/2017 9:08 PM
 

Browsed the zip files, can't find any JavaScript files.  BTW, that's a great Razor MVC sample.  I want to reuse my own data layer, will use Bootstrap to create my own layout.  To get my data calls to work and properly populate my View objects I only have to get the Ajax url: attribute to work.

What I did get was this code, from a buddy who develops modules but I'm still dead in the water.  It is just a path issue, all other calls to the MVC controllers which do use Razor work.

I have a working data layer that can be reused.  All other page functions work, just need to get the path issue handled.  I'm not doing anything different than is done in regular ASP.Net MVC but I'll be damned if that ports over to DNN -- sorry I'm a bit frustrated here.

I need a good JavaScript sample if there is one.

var serviceFramework = $.ServicesFramework(412);  <-- had to hard code moduleId, looks like the ServicesFramework doesn't know what it is, that's odd

$.ajax({

url: ' /DesktopModules/MVC/FirstDALMVC/API/Item/Test' <-- inserted 'API' into the path

, beforeSend: serviceFramework.setModuleHeaders <-- included this attribute

, type: 'POST'

, cache: false

//, data: {

// 'testData': 10

//}

//, dataType: 'json'

, success: function (data) {

got to success');

},

error: function (request, error) {

ein, Tod');

}

});

});

 
New Post
6/15/2017 9:44 PM
 
There are no javascript files but index.cshtml has some javascript calls to backend.

Check https://github.com/dnnsoftware/Dnn.Pl...

Amarjit Dhunna Dnn Corp.
 
New Post
6/16/2017 8:45 AM
 

Thanks for the prompt replies but this code doesn't have the MVC path.  Only the method calls that will, under the hood, utilize it.

It's encapsulated, already tried this route.

I've already called and emailed DNN Corp Sales requesting a paid support instance to resolve, quite frankly, the circumstances of not having non-Razor docs to hand.  The MVC path should be provided and it should be known where it is already.

Coding using .ascx files for views should be supported just as much as Razor is.  It would be *loads* of work to code using this method when already 90% of the code we have can be updated to .Net 4.5 and re-used.  And writing the Ajax calls to get the data to the front end would be trivial if I had the MVC path.

It may not sound like I mean it when I say thanks for the fast replies.  That means a lot that the community edition is supported with such professionals and fast.  But in my case I'm not getting the answers I need fast enough and I'm not going to make my client wait any longer.

It's paid support today or we waste another weekend.  I can write all the code I have to and have the 4-5 modules done and working by tomorrow afternoon but can't get the very simple code items I need to do it.

Thanks again and I do meant it -- THANKS! :) 

But paid support is apparently the only option.

Best,

Michael Durthaler

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCan't seem to get a simple Ajax call to workCan't seem to get a simple Ajax call to work


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

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

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. 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.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out