i have function get_rule(rulename) in controller/team/index_controller.rb which is returnig a map and i have javascript from which i want to call this function . Right now i am doing an ajax call from this script
jQuery.ajax({
url: "<%= Rails.configuration.url_prefix %>/team/index/get_rule_attribute_values",
type: "POST",
dataType : "json",
success: function(){
console.log("success");
},
error: function(jqXHR, textStatus,errorThrown){
var requestResponse = {
httpStatus: jqXHR.status,
error:jqXHR.statusText,
};
console.log("requestResponse");
// Notify the user so he might not wonder.
alert('Something went wrong, Please try again');
// Report it back for fixing it
// Only for debuggify users
var ajaxErrors = debuggify.Logger.get('ajax_errors');
ajaxErrors.attach(requestResponse);
ajaxErrors.error('Caught ajax error');
}
});
my getrule func
def getrule(rule_attribute_name)
# rule_attr_value = RuleAttribute.get_rule_attributes rule_attribute_name
# rule_attribute_values_hash = JSON.parse(rule_attr_value)
# rule_attr_values = rule_attribute_values_hash["rule_attribute_values"]
# rule_attribute_values = Hash.new
# rule_attr_values.each do |value|
# rule_attribute_values.store(value["internal_name"],value["display_name"])
# end
respond_to do |format|
format.json {render :json =>{:error => false, :message => "test"}}
return rule_attribute_values
end
please provide me some suggesstion or code so that i can make a call . i spent whole day on single but don't want to waste more time on this.And i want the map returning from controller function in a variable i.e. i want response of ajax into a variable