how can i send a parameter to server-side for Jsp?
how can i send a parameter to server-side for Jsp?
i want send a parameter(date) to server-side,like this:
[code]
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "HaiDeBao.jsp?viewDate='2011-10-03'",//fail
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]
and Jsp page how do it ?
How to send parameters
how to receive parameters?
i am chinese and my english is poor,who can help me?thank you very much
[code]
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "HaiDeBao.jsp?viewDate='2011-10-03'",//fail
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]
and Jsp page how do it ?
How to send parameters
how to receive parameters?
i am chinese and my english is poor,who can help me?thank you very much
This discussion has been closed.
Replies
I think it's simply a matter of your formatting. You have single quotation marks (') around your date, which are reserved characters in URIs. If your application is handling them correctly, that's good. Otherwise, it's safer to use something like:
HaiDeBau.jsp?viewdate=2011-10-03
--
Additional thoughts: are you SURE it's the URL that's failing? Maybe the resource is found, but it is not returning valid JSON?
--
Interesting side-note: the way we are receiving URLs to our Servlets, we need an extra slash. So when we call to a Servlet, we format it as:
MyServlet/?parameter=foo
I don't think this is your problem; our web server handles requests for JSPs in the expected way. But I wanted to mention it "just in case".
In fnServerData, aoData is an array of objects representing name/value pairs - these will be formatted as your querystring/postdata in the .ajax() call. You can add your param to this list and the it will be sent with the .ajax call (which you are calling with POST) to your server.
[code]
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "HaiDeBao.jsp",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push({ name: "viewDate", value: "2011-10-03" }); // add param to aoData
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]