java - using ajax send large json data to controller -


this jsonexample.jsp file,

    <!doctype html>         <html>         <title>jquery function demo - jquery4u.com</title>         <head>         <script             src="http://www.jquery4u.com/function-demos/js/jquery-1.6.4.min.js"></script>         <script src="http://www.jquery4u.com/scripts/function-demos-script.js"></script>           <script>             function call() {                  //var url = 'http://192.168.10.82:8081/formulator-service/tracks?callback_track=processjson';                  var url = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=processjson&tags=monkey&tagmode=any&format=json";                  $.ajax({                     type : "get",                     url : url,                     async : false,                     jsonpcallback : "processjson",                     contenttype : "application/json",                     datatype : "jsonp",                     success : function(json) {                          alert(json.title);                         //alert(json.name);                          controllercaller(json);                      },                     failure : function() {                         alert("there error");                     }                 });              }             function controllercaller(json) {                 //var dummy = "poiuytre";                  alert("in controller caller");                 //var url="/controllercall";                 $.ajax({                     type : "post",                     url : "controllercall",                     async : false,                     data : {                         jsondata : json                     },                     success : function() {                         alert("in controller ajax function");                     },                     failure : function(error) {                         alert("somthing went wrong");                     }                  });             }         </script>           </head>         <body>             <button onclick="call()">get json</button>         </body>         </html> 

and basecontroller.java file,

package com.web.springmvc.controller;  import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.requestparam; import org.springframework.web.bind.annotation.responsebody;  @controller @requestmapping("/") public class basecontroller {      @requestmapping(method = requestmethod.get)     public string printhello(modelmap model) {          return "jsonpexample";      }      @requestmapping(value = "/controllercall", method = requestmethod.post, produces = "json/application")     public @responsebody     string controllercall(             @requestparam(value = "jsondata", required = true) string data) {         system.out.println("this in second function");          return data;      }  } 

the problem data sent view cannot received in controller. can suggest proper way so? thank you.

the url you're sending is: "controllercall" should url used in function call.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -