Call ajax to servlet call always the error function
<p>I'm trying to do some tests with ajax and servlet but when I launch the application, the servlet return always 'error'</p>

<pre><code>package servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet(name = "ServletCatalogue", urlPatterns = "/test")
public class ServletCatalogue extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        out.write("test");
    }
}
</code></pre>

<pre class="lang-js prettyprint-override"><code>$(function() {
    $("#catalogue").on('click', function() {
        $.ajax({
            url: "/test",
            type: "GET",
            success: ok,
            error: error
        });
    });
});

function ok() {
    alert("fine")
};

function error() {
    alert('error')
}
</code></pre>

<p>Why does it always print <code>"error"</code>? I know that the JS calls the servlet correctly  because I put a <code>system.out</code> to check that.</p>