OK, so the title basically says what I want to do. For the past few hours, I've been trying to use jQuery.post to submit a JSON string to a JSP page. So my Javascript for the file iMakeTheJSONstring.jsp looks like:
Code:
jsonString = new Object();
jsonString.user = username;
jsonString.field = textBoxId.replace(/[0-9]/g,"").replace("input","");
jsonString.data = document.getElementById(textBoxId).value;
var toSubmit = JSON.stringify(jsonString);
I've tested these lines of code by outputting toSubmit to an alert box. These lines build the JSON string correctly. However, the next line's giving me a lot of trouble:
Code:
//"info" is simply a reiteration of the original JSON string sent to update.jsp
$.post("http://localhost:8080/armControl/admin/update.jsp", toSubmit, function(info) {
alert(info);
At the moment, update.jsp is only as follows:
Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
out.print("hello");
%>
Even this doesn't return a value for "info," and I don't get an alert box to pop up.
I had previously tried to access the information with
Code:
String randomVar = request.getParameter("whatever").toString();
However, this isn't working.
I really appreciate your reading my post, and I will certainly appreciate any thoughts you have on my problem. I'm new to Java/JSP, and this whole issue is exhausting to me!