I'm not convinced your code is correct. Try this and see what happens:
$("#edit-item-btn").live('click', function() {
var name = this.id;
$.getJSON("InfoRetrieve",
{ theName : name },
function(data) {
alert(data.name);
});
});
This should work if InfoRetrieve responds with a JSON string like this:
{"name":"Sally Smith"}
A few things to note:
- You are sending a request to ./InfoRetrieve in the same directory as the page is located. If you are using a servlet, is that actually correct? Or do you want "/servlet/InfoRequest"?
- You are sending data as input to InfoRetrieve with a key of "theName" and a value of whatever is "this.id" is. Does your servlet know how to accept this input?
- You are then receiving back a response from InfoRetrieve, and "data" is set to an object that represents the json in the response. You need to then access properties of data to get at values in the response.