calling AJAX MVC DNN - model-view-controller

What is the proper way to call an MVC method via AJAX in DNN?
I tried the following URL:
(Does not work)
/DesktopModules/MVC/MyModule/MyController/MyAction
(Works but returns full html instead of Json)
/Home/ModuleID/432/Controler/Action/

Related

ASP.NET Core PageRequestManager Ajax Call equivalent

In ASP.NET Web forms we had access to Sys.PageRequestManager to determine the ajax call finish. How can we run a JS after ajax call finish in ASP.NET Core 2.2?
I do not have access the the Ajax call, it runs by a plugin, I have to write some code to make some changes to loaded data with that plagin ajax.

How to Pass custom parameters to liferay's default render_portlet AJAX method

I am trying to pass client's local time offset(from javascript) to server.
http://localhost:8080/c/portal/render_portlet?p_l_id=10418&p_p_id=XXXcontacts_WAR_XXXcorebankingportlet&p_p_lifecycle=0&p_t_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_pos=0&p_p_col_count=1&p_p_isolated=1&currentURL=%2Fweb%2Fxxxx
<render-weight>0</render-weight>
The portlet gets loaded by the liferay's built in Ajax method.
I need to intercept the Liferay's default render portlet ajax method.
A renderURL has not a lot to do with Ajax - that's the realm of a resourceURL. You pass parameters just like to any other URL by adding them to the URL - in POST as well as in GET. You probably have constructed the above URL somehow, e.g. through <portlet:renderURL />, but you should use <portlet:resourceURL /> instead. There's also a Liferay object available so that you can construct those URLs dynamically through Javascript.

Scala Play - calling controller method from view doesn't load a new page

I display information, gather some user's input, and call a controller method using ajax/java script call from the view. However, instead of displaying a new/different html page, the controller method returns back to the original html page that I called jscript from.
Is this because of ajax call? How do I make sure that controller method would display the html file it's supposed to, instead of staying on old html page?
It sounds to me like what you want to do is to open a different url than the one you are on. To do that you do not use ajax. Instead try using javascript to change window.location to tell the browser to go to the url (or 'call your controller'). It looks like this:
window.location.assign("/your/controller/url"); // or
window.location = "/your/controller/url";
There is more to read about it here: https://developer.mozilla.org/en-US/docs/Web/API/Window.location
You can think of ajax as a separate little browser that lets you call the web server but letting you handle what comes back with javascript rather than always showing it to the user. So if you want to do the call with ajax but get the response HTML into your page, you are responsible for taking that response and inserting it into the DOM.

Unable to Successfully Update Page Content via ajax

I have a mobile version of a website built in jQuery mobile and living on a dedicated "m.myurl" subdomain. The full desktop version of the site is in Wordpress. My goal is to have updates entered via Wordpress to the desktop site to show up dynamically on the mobile site as well. I am generating the page content from the individual pages of the desktop site via JSON feeds, and have confirmed that the JSON feeds are good (i.e.: if I enter their URL into a browser, I get a good JSON object). However, the AJAX call on the jQuery mobile site refuses to work. I have debugged to the point that I am not receiving any errors in my console, but when I attempt to log the response from the AJAX call to troubleshoot, it consistently shows in the log as undefined, so I am not receiving known good JSON objects.
The functions I'm using to make the AJAX call are as follows:
function processResponse(response){
var update = $(response).find('content');
$('.content').append($(update).html());
};//ends processResponse
function processJSON(url){
$.ajax({
url: url,
data: null,
success: processResponse,
dataType: 'jsonp',
});//ends ajax
};//ends processJSON
I've set the three JSON URL's equal to variables, but have tried calling the function with the URL passed in instead of the variable, to no effect. The 'processJSON" function is called within the content div of each page section of the jQuery mobile index.html file within a $(document).ready.I'm using 'jsonp' as the dataType, as I assume that calling from a subdomain to a main-level domain would be considered a cross-domain call. That said, I'm trying to get this to work locally, and haven't placed it on a test server yet.
Any assistance is appreciated. Thanks!

Ajax load a page like an include

I have a problem: I need to load a set of includes with ajax, but when I make the ajax
and request the current URL, I get the page url.
I have a problem when I call a page via ajax; the problem is when I try to get the request
URL in the page which is called with ajax, because it doesn't work like an include.
For example: I have my page "prueba.adp" and "prueba-ajax.adp"
The page prueba.adp calls via ajax to prueba-ajax.adp.
So when I try to get the request URL in prueba-ajax.adp I get prueba-ajax.adp, but
if I set an include I get prueba.adp.
Do you know any way to execute the ajax page and get the request url of the page which made the ajax call?

Resources