Dan Dinu Dan Dinu - 1 year ago 45
Ajax Question

How to send parameters with jquery $.get()

I'm trying to do a jquery GET and i want to send a parameter.

here's my function:

$(function() {
var availableProductNames;
$.get("manageproducts.do?option=1", function(data){
availableProductNames = data.split(",");;
source: availableProductNames

This doesn't seem to work; i get a null in my servlet when i use

If i type the link into the browser http://www.myite.com/manageproducts.do?option=1 it works perfectly.

I also tried:

{option: "1"},

which doesn't work either.

Can you please help me?


also tried

type: "GET",
url: "manageproducts.do",
data: "option=1",
success: function(msg){
availableProductNames = msg.split(",");
source: availableProductNames

Still getting the same result.


If you say that it works with accessing directly manageproducts.do?option=1 in the browser then it should work with:

$.get('manageproducts.do', { option: '1' }, function(data) {

as it would send the same GET request.