0

I am creating module for frontend and backend and want to run ajax with in the modules. My ajax is perfectly working on frontend but it doesn't work on admin side.

My Ajax URL is http://127.0.0.1/mag/createmenubackend/create/ajax/?isAjax=true which goes to 404.

The result but AJAX goes to 404 Not Found. What's the issue i didn't get this.Any Help is appreciated.

1 Answer 1

1

I think you have missed "admin" in you'r URL before createmenubackend.

url: 'http://hl.local/admin/createmenubackend/create/ajax/'+'?isAjax=true'

Actually, you have to call Direct URL function in JS otherwise you have to change URL again and again on different platforms like local, stage & Production like EX. below:

define([ 'mage/url' ], function (urlBuilder) {
var customLink = urlBuilder.build('customer/account/login');
console.log(customLink); });

3
  • Thanks for your answer i have done that actually my url is diffrent and you are right i have move my js part in phtml file with <?php echo $block->getUrl('name_of_url'); ?> and it worked. Will you please tell me how to save that data in database in my custom table i have created table in my database.
    – Prits
    May 16, 2021 at 9:25
  • There are multiple links, you can refer below one or just google it simply: magento.stackexchange.com/questions/303958/…
    – Ankit
    May 16, 2021 at 9:44
  • Thanks for the link @Ankit I have done that and it worked will you please tell me how to insert image data in database in Magento 2.
    – Prits
    May 16, 2021 at 13:31

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.