I have created an ajax call in jquery to my server, the trouble I'm facing now is that my response is printing ? even though the correct integer value is written into the output stream. Ajax function is given below. 

```
$dntb.on('click', 'button', function(event) {
                var i = $(this).closest('tr').index(); //have to get the row where the button is clicked 
                var sditmId = $("#sditm").val();
                var sdhedId = $("#sdhed").val();
                $.get('getstock', {
                    sditmId: sditmId,
                    sdhedId: sdhedId
                }, function(response) {
                    alert(response);
                    var stk = ""+response;
                    $("#stk").val(stk);
                });
            });

```

This function is called on click of an issue button in my table shown below

![Issue button in display notes page](https://i.stack.imgur.com/JzqIi.png)

The server code is given below

```
int stk = null;
switch (userPath) {
        case "/getstock":
            stk = opo.getStockData(request.getParameter("sditmId") request.getParameter("sdhedId")); //value to write into the output stream.
            break;
        case "/temp":
            //er = opo.checkCatUniqueForEdit(request.getParameter("catName"), request.getParameter("catId"));
            break;
    }
System.out.println(stk); //Printing correctly
    response.setContentType("text/html");
    response.getWriter().write(stk);

```

Code to get the value

```
public int getStockData(String sditm, String sdhed) {
    int stk = 0;
    try {
        String query = "Select stk.Stk_instk from tbstk stk inner join tbsditm itm on itm.Sditm_prdid=stk.Stk_prdid where itm.Sditm_sdhed=" + sdhed + " and itm.Sditm_id=" + sditm;
        Statement stmt = dcon.con.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        if (rs.next()) {
            stk = rs.getInt("Stk_instk");
        }
    } catch (SQLException ex) {
        Logger.getLogger(Op_OrdConf.class.getName()).log(Level.SEVERE, null, ex);
    }
    return stk;
}

```

The ajax call happens successfully but when I alert the response I'm getting and I'm getting the value correctly in the server but in the client side it is ?. Please help me solve this