I have a custom.js with post request

function setPrayerTime(cityId) {
    var request = $.ajax({
        url: "http://site.com/mymodule/namaz_mob/prayer.v2.php",
        type: "POST",
        data: { cityId : cityId },
        dataType: "json",
        beforeSend: function( xhr ) {
            $( ".namazcontainer" ).addClass( "times-loading" );

So, my PHP file is located at site.com/mymodule/namaz_mob/prayer.v2.php, but joomla always redirection to site.com/prayer.v2.php if you're on the front page of the site i.e. http://site.com the ajax request will go to http://site.com/prayer.v2.php while on a page at http://site.comblog/mypost01 it will map to http://site.com/blog/prayer.v2.php. How to send ajax request of the address where located my php file prayer.v2.php within com_ajax

  • is mymodule a module in your modules folder or external folder placed in root directory?
    – Liz.
    Commented Oct 18, 2017 at 10:50

1 Answer 1


Likely there is some URL rewriting going over there.... What happens if you try the url like: '/mymodule/namaz_mob/prayer.v2.php' ?

However, I would recommend to use com_ajax the Joomla AJAX interface for making your ajax calls to your module's php functions. Read here for this.

Also do a search in JSE and you will find many similar topics that might help you. https://joomla.stackexchange.com/search?q=ajax+module

  • 'mymodule/namaz_mob/prayer.v2.php' same results, ajax post request redirection to site.com/prayer.v2.php
    – Ummet
    Commented Jul 20, 2017 at 6:58
  • sorry try also with a slash in front of mymodule, like '/mymodule/namaz_mob/prayer.v2.php'
    – FFrewin
    Commented Jul 20, 2017 at 7:00
  • Same result even if you make a request from another domain
    – Ummet
    Commented Jul 20, 2017 at 7:07
  • @Ummet - yes likely it is rewritten - as joomla has to pass this through index.php
    – FFrewin
    Commented Jul 20, 2017 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.