JavaScript Pass JSON value from JavaScript to JSP pass json value in javascript,pass json value as string,

I am working on a code to get a JSON value from javascript to my JSP. The JSON value is a boolean, so I could use if/else in my JSP script. I have two javascript files and a JSP.

Widget.js

initialize: function(conf){
  _Widget.prototype.initialize.call(this);
  _.bindAll(this, 'render', 'onPChange', 'applyInfo');
  this.listenTo(this.model, 'sync', this.render);
  this.listenTo(this.model, 'error', this.handleError);
  conf.getBus().on('/p'. this.onPChange);
  return this;
},
serializeData: function(model){
  return _.extend({}, this.resStr, model.attributes);
}
render: function(model, resp, options){
  var data;
  f = JSON.stringify(data.sFund);
  console.log("Result value: " + f);
}

index.js

$('#wgtWidget').objFactory(this.classes, this.wgts, this.mdls, conf);
this.mdls['wgtWidget'].render();

Portlet.jsp

<div data-wgt='Widget' data-model='Model' id='wgtWidget' class='model'></div>
<script>
  var f;
  console.log("Returned JSON value: " + f);
  if(f==true)
     console.log("Success");
</script>

I grunt the javascript files to make a minified main.js file. When I tried commit the above code, I get

conf.getBus is not defined 

error, while I get the log as:

Result value: true
Returned JSON value: undefined

If I change the JSP as:

Portlet.jsp

<!-- <div data-wgt='Widget' data-model='Model' id='wgtWidget' class='model'></div> -->
<script>
  var f;
  console.log("Returned JSON value: " + f);
  if(f==true)
     console.log("Success");
</script>

Now I get the:

this.mdls.wgtWidget is not defined

and no other log.

I tried removing the line

this.mdls['wgtWidget'].render(); 

from the index.js code. This makes the page load without errors, but no other log.

Can you please help me get this over with? I am struggling to find an answer from 3 days.

Thank you.

Answer:1

since yesterday i started javascript to make a hovering effect that applys to the body of the page(i want to change the background color of the body of the page while hovering a div), I've watched ...

since yesterday i started javascript to make a hovering effect that applys to the body of the page(i want to change the background color of the body of the page while hovering a div), I've watched ...

  1. javascript mouseover event
  2. javascript mouseover mouseout
  3. javascript mouseover tooltip
  4. javascript mouseover event listener
  5. javascript mouseover vs mouseenter
  6. javascript mouseover vs hover
  7. javascript mouseover effects
  8. javascript mouseover not working
  9. javascript mouseover selenium
  10. javascript mouseover highlight
  11. javascript mouseover class
  12. javascript mouseover image change
  13. javascript mouseover change color
  14. javascript mouseover show tooltip
  15. javascript mouseover child element
  16. javascript mouseover text box
  17. javascript mouseover image
  18. javascript mouseover element
  19. javascript mouseover div
  20. javascript mouseover show div

Consider the following piece of code: function A() { for(i = 0; i < 3; i++) { console.log("---" + i + "---"); B(); } } function B() { for(i = 0; i < 3; i++) ...

Consider the following piece of code: function A() { for(i = 0; i < 3; i++) { console.log("---" + i + "---"); B(); } } function B() { for(i = 0; i < 3; i++) ...

  1. javascript loop through array
  2. javascript loop through object
  3. javascript loop array
  4. javascript loop over array
  5. javascript loop through json
  6. javascript loop through object properties
  7. javascript loop through string
  8. javascript loop through map
  9. javascript loop through dictionary
  10. javascript loop through json object
  11. javascript loop continue
  12. javascript loop through array of objects
  13. javascript loop n times
  14. javascript loop through select options
  15. javascript loop through table rows
  16. javascript loop through elements
  17. javascript loop x times
  18. javascript loop through htmlcollection
  19. javascript loop through child elements
  20. javascript loop through associative array

I have a clickable table row and checkbox in that row. When user click on that row, user will be redirected to other page. That was expected behavior. Now the problem is when user click on checkbox, ...

I have a clickable table row and checkbox in that row. When user click on that row, user will be redirected to other page. That was expected behavior. Now the problem is when user click on checkbox, ...

I am new to javascript, The below question should return 1 according to my knowledge about javascript, but it's returning "undefined". could anyone tell me why it's not returning 1? var foo = { ...

I am new to javascript, The below question should return 1 according to my knowledge about javascript, but it's returning "undefined". could anyone tell me why it's not returning 1? var foo = { ...