0

I'm currently using the com_ajax component in order to make an internal ajax call/response in my custom module, but upon the ajax call I immediately get a 500 error.

This is the code in my default.php file:

function getApi(bdcApi) {
    Http.open("GET", bdcApi);
    Http.send();
    Http.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            //result.innerHTML = this.responseText;
            var data = JSON.parse(this.responseText);
            var zip = data.postcode;
            result.value = zip

            console.log(zip);

            jQuery.ajax({
                type: 'GET',
                url: "<?php echo JURI::base() . "index.php?option=com_ajax&module=hunter_maps_dev&method=getStoresByZip&anyparams="?>"  + encodeURIComponent(zip) + "&format=json",
                success:function(data){
                    console.log('success');
                },
                error: function(xhr, status, error) {
                    alert(xhr.responseText);
                }
            });  
        }
    };
}

My module is called mod_hunter_maps_dev and I have a method in there called getStoresByZipAjax where I'm only trying to return a test string right now. Does everything look correct based on that? I've seen where some people had to load the Joomla API in the helper.php file but I'm not sure how to do that or if it would even work.

Any help is appreciated

1
  • 1
    Is this still an issue given your later question answered by @jamesgarret ?
    – Irata
    Sep 24 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.