How to get database value from ajax in joomla module?

I am creating a module where I want to get the database value from ajax. Does anyone have a solution to this problem or any example, please help me ... can someone give me the correct way for this ........

this is my code jquery-

jQuery('.type').bind('click', function() {
      var feedId = jQuery(this).attr('id');
      alert(feedId);
    jQuery.ajax({
        type: "POST",
        url: "modules/mod_feedback/ajax.php",
        data: {"Type":feedId},
        success: function(reviews){
            //jQuery(".show").html(response);
            alert(reviews);
        }
    });
  });

and this is my code ajax.php-

require_once( 'helper.php' ); 
$reviews = modfeedbackHelper::getFeedbackResultIdea();
echo $reviews;
+3
source share
2 answers

Here is the ajax call.

 $.ajax({
            type: "POST",
            url: "//PATH of ajax.php",
            data: { //Data to pass},
            cache: false,
                success: function(html)
                {
                    //DO SOMETHING  
                }
            });

and in ajax.php

 require_once( 'helper.php' );

 $reviews = modfeedbackHelper::getFeedbackResultIdea();

 echo $reviews; exit;

That should do :) :)

0
source

First of all, you are trying to make an ajax call for files inside the module and not part of the module, so it acts like an external php file

modules/mod_feedback/ajax.php . ajax , .

jQuery('.type').bind('click', function() {
      var feedId = jQuery(this).attr('id');
      alert(feedId);
    jQuery.ajax({
        type: "POST",
        url: "index.php?option=com_yourcomponent&task=yourcontroller.your_function",
        data: {"Type":feedId},
        success: function(reviews){
            //jQuery(".show").html(response);
            alert(reviews);
        }
    });
  });

your_function

require_once( JPATH_SITE.'/modules/mod_feedback/helper.php' );

 $reviews = modfeedbackHelper::getFeedbackResultIdea();

 echo $reviews; exit;

, Joomla ajax.php, . .

, .

0

All Articles