Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:51:06+00:00 2026-05-30T04:51:06+00:00

My $.getJSON method is calling the servlet but callback function is not working. this

  • 0

My $.getJSON method is calling the servlet but callback function is not working.

this is my js file:

$(document).ready(function() {
$('p').addClass('highlight');
receiveData();
});

function receiveData(){

    alert('receive data');
    $.getJSON('ProcessForm', function(data){alert('hi')});
    }

“Receive data” alert is coming on the screen, as well as call to ProcessForm Servlet is going, But the alert in the callback method is not coming.

This is what I had written in the ProcessForm Servlet

package com.nagarro.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.nagarro.json.DictionaryList;


public class ProcesFormServlet extends HttpServlet
{

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse response)
            throws ServletException, IOException {

        DictionaryList dictionaryList = new DictionaryList();
        System.out.println("haan ji sir");
        // Write response data as JSON.
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        response.getWriter().write(new Gson().toJson(dictionaryList));
        super.doGet(req, response);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse response)
    throws ServletException, IOException {

        DictionaryList dictionaryList = new DictionaryList();
        System.out.println("haan ji sir");
        // Write response data as JSON.
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        response.getWriter().write(new Gson().toJson(dictionaryList));
        super.doPost(req, response);
    }

}

Anybody having any idea what could be the issue

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:51:07+00:00Added an answer on May 30, 2026 at 4:51 am

    Is it possible that you’re not returning well-formed JSON? That would cause jquery to not execute the callback code.

    If you’re sure you are (run it through a JSON Lint site to double check), make sure you’re specifying Content-type: application/json in the header for the HTTP response

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function calling a controller method in MVC3. $.getJSON('@Url.Action(LoadCitiesByProvince, Property)', { id:
I am trying to figure out why my $.getJSON method does not seem to
$.getJSON('http://twitter.com/followers/ids.json?screen_name=' + query1 + '&callback=?', function (data) { console.log('JSON data string 1 is: '
$.getJSON('ajax_popup.php', function(data) { var popupDiv = decodeURIComponent(data.data); $('body').append( popupDiv ); }); This piece of
This works fine: $.getJSON(http://localhost:59396/xxxWeb/ CarouselHandler.ashx?action=getproducts&ids= + ids, function(data) { carousel.size(allProductIDs.length); if (numberOfImagesLeftToShow < numberOfImagesToDisplay)
$(function(){ $.getJSON('http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=ElicitBelief&api_key=25135a535781328243f9e31968abc14&format=json', function(data) { alert(data) }); }); Firebug says: GET http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=ElicitBelief&api_key=25135a535781328243f9e31968abc14&format=json 200 OK 144ms
I have a JavaScript class that has a method: function someClass() { this.someMethod =
I made a small example HTML page to get JQuery's getJSON method working. It
I am calling the following method in my controller using $.getJSON() [return: JSONReturnBinder] public
UPDATE 3 var local = 'http://localhost:1163/CustomerService.svc/getcustomer?method=?'; var dev = 'http://yourserver.com/CustomerService.svc/GetCustomer?method=?'; $.getJSON(dev, function (customer) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.