0

I have a json like

var rules=[
        {
            "ruleId": "1234",
            "version": "R1234",
            "name": "Usage crossing 50MB",
            "description": "Find usage more than 50mb",
            "active": true,
            "created_by": "Rahul",
            "create_date": "2015-08-18",
            "modified_date": "2015-08-22",
            "modified_by": "Subho",
            "category": {
                "name": "High Usages Rule",
                "id": "26"
            }
]

Now I want to call a java page or function where i want to get these data so i put it on DB.

this is my controller

 (function(){
     "use strict";

  angular
    .module("RulesEngine")
    .controller("RulesEditCtrl",
    ["rules","$state",RulesEditCtrl]);

  function RulesEditCtrl(rules, $state){
    var vm=this;
    vm.rules=rules;

    vm.submit=function(){
        vm.rules.$save(function (data) {
            toastr.success("Save Successful");
            vm.ruleJson=data;
        });
        console.log(vm.ruleJson);
        //in yhis vm.ruleJSON holds the the updated json. it prints fine in console.log
    }
}

}());

I want to call a function using $ajax or $http.get() to call a function insertEntry() which is in a java page named ShowJson.java. please help me to call the function and send the data. I tried

$.ajax({
            url : "insertEntry?rule="+vm.ruleJson,
            type: 'POST',
            dataType : "json",
            success : function(data) {
                console.log("inserted");
            },error : function(data) {
            }
        });

But its not working...

5
  • "Not Working" is always the worst description of a problem, what is expected what did you test what did you see? In angular you should stop using jQuery until you know what you have in the framework and you'll probably find you don't need jQuery at all, use $http for ajax calls. Commented Aug 24, 2015 at 14:06
  • You need all the server side app layer, what did you have planned to implement? J2EE rest services? A single java files could not be called in that way!! Commented Aug 24, 2015 at 14:09
  • Beyond not working being meaningless...also include errors thrown. You have to help us help you. Injecting rules into controller looks suspicious to me as invalid injection Commented Aug 24, 2015 at 14:13
  • I dont want to ust spring or rest api.. I just need to send the json to a java page named ShowJson.java. Commented Aug 25, 2015 at 7:33
  • try this solution we should use POJO to do that: stackoverflow.com/questions/30989391/… Commented Dec 10, 2015 at 18:52

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.