0

I am working on extjs3.2 Grid.I am using spring and hibernate.I am using below link

http://loianegroner.com/2010/09/extjs-spring-mvc-3-and-hibernate-3-5-crud-datagrid-example/

I am adding my data using

modelMap.put("val", '12345');

Now my question is how will i get val variable in my javascript file.I am already using

modelmap.put('data',city)

Please Help

Thanks

2
  • try in javascript like: var val = ${val}; Note: on the jsp not external js file. Commented Apr 17, 2014 at 3:12
  • @Rembo are u sure it working?? Commented Apr 17, 2014 at 5:30

2 Answers 2

1

You could try to identify the element using jQuery class selector and calling innerHTML and assign it to a variable:

var val = $("class-selector").innerHTML
Sign up to request clarification or add additional context in comments.

Comments

0

You won't be able to fetch it in a JS file. Since the model map will only be available when the server compiles and prints out the JSP page, the variables are available only in a JSP file and not in a JS file.

If you have a JS file and want to use it, you'll need to store the value in a variable in a JSP file and then access the variable in the JS file.

So, JSP code is:

var myVariable = ${val};

then put the JS file:

<script type="text/javascript" src="myfile.js">

Inside myfile.js, you can use the variable:

Ext.request({
  url : 'myUrl/'+myVariable,
  success:..
});

Comments

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.