ajax - Spring dojo request issue -


i quite new spring framework , have problem. have page a.jsp , in page have link page b.jsp

<c:url value="${pagecontext.request.contextpath}" var="contextpath" /> click <a href="${contextpath}/pageb">here</a> 

and in controller

@requestmapping("pageb") public string pageblink(sitepreference sitepreference, device device, model model) { return "pageb";      } 

now on page b.jsp want invoke ajax call.

i have link <a href="javascript:myfunction();">send request</a>  function myfunction(){ dojo.xhrget({ // url of request url: "requestpage", method: "post", handleas: "json", // success callback result server load: function(jsondata) { var content = "";                                 dojo.foreach(jsondata.newsitems,function(locationpoint) { // build data json content += "<p>" + locationpoint.name + "</p>"; content += "<p>" + locationpoint.latitude + "</p>"; content += "<p>" + locationpoint.longitude + "</p>"; content += "<p>" + locationpoint.number + "</p>"; }); }, // error handler error: function() { // nothing -- keep old content there }, // generate variable prevent browsers caching preventcache: true }); } 

and add controller

@requestmapping(value="requestpage", method = requestmethod.get) public myobj returnevselocations(){     logger.log(level.info, "return evse locations --------------");     myobj myobj = new myobj();     // add stuff obj      return myobj; } 

but request requestpage.jps ... want work in page (b.jsp). more welcome. thanks!

i found issue. in fact there 2 problems 1. in ajax call must have dojo.foreach(jsondata, ...) instead dojo.foreach(jsondata.newsitems, ...) 2. in controller in on method must add annotation

public @responsebody myobj  

i hope front same issue.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -