How to get an AJAX response from controller to jspHow do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How to get the children of the $(this) selector?How to get an enum value from a string value in Java?How can I get query string values in JavaScript?How to avoid Java code in JSP files?How do I remove a particular element from an array in JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I return the response from an asynchronous call?Handle file download from ajax post

Why does sound not move though a wall?

Where is the documentation for this ex command?

SafeCracker #3 - We've Been Blocked

Frequency of specific viral sequence in .BAM or .fastq

Would glacier 'trees' be plausible?

How to make a chinese doggy bag?

I need a disease

How can internet speed be 10 times slower without a router than when using a router?

How can I support myself financially as a 17 year old with a loan?

What are the differences between credential stuffing and password spraying?

In Russian, how do you idiomatically express the idea of the figurative "overnight"?

Adjacent DEM color matching in QGIS

Target/total memory is higher than max_server_memory

Why did Thanos need his ship to help him in the battle scene?

Why did the Apollo 13 crew extend the LM landing gear?

Building a list of products from the elements in another list

Wrong answer from DSolve when solving a differential equation

How do inspiraling black holes get closer?

Appropriate certificate to ask for a fibre installation (ANSI/TIA-568.3-D?)

PWM 1Hz on solid state relay

IP addresses from public IP block in my LAN

How long would it take for people to notice a mass disappearance?

What was Bran's plan to kill the Night King?

What is the solution to this metapuzzle from a university puzzling column?



How to get an AJAX response from controller to jsp


How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How to get the children of the $(this) selector?How to get an enum value from a string value in Java?How can I get query string values in JavaScript?How to avoid Java code in JSP files?How do I remove a particular element from an array in JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I return the response from an asynchronous call?Handle file download from ajax post






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a spring boot application, I want to make a call from the search page(jsp) to controller, fetch the response and update in the jsp by AJAX. Right now on making a submit call, I get nothing. (to add, if I make a rest api call to controller I get a response from db i.e. http://localhost:8080/problems/problemId). Basically I need to know how to combine the response from ui to api. Please suggest if any mapping or bind varibles to be added.



my jsp



<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file = "header.jsp" %>
<div>
<div>
<h1>Lookup from Oracle database</h1>
</div>
<div>
<h2>$message</h2>

<td>Search Category:</td>
<td>
<select name="searchcategories">
<option value="-1">-Select Category-</option>
<option value="problem">problem</option>
<option value="attachment">attachment</option>
<option value="tstt">tstt</option>
</select>
</td>
<td>Entity Id:</td>
<input type="text" name="problemId" id="search_data" class="form-control" placeholder="Search problem no..">
<button type="submit" id="submit_btn" onclick="">Search</button>

</div>
</div>

<%@ include file = "footer.jsp" %>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()

$('#submit_btn').click(function()
var problemId = $('#search_data').val();

$.ajax(
type: "GET",
dataType : "json",
url : "http://localhost:8080/problems/" + problemId,
success : function(data)
/* $("#response").html(data); */
var parsed_data = JSON.parse(data);
console.log(parsed_data.success);


);
return data;
);
);

$("form").submit(function()
alert("Submitted");
);


</script>
</html>


my controller class (gives response when I call directly through rest i.e. http://localhost:8080/problems/problemId):



@RestController
@RequestMapping("/problems")
public class BugController

@Autowired
BugRepository problemRepository;

@GetMapping("/problemId")
public Bug getProblemById(@PathVariable Long problemId)
return problemRepository.findByProblemId(problemId);




Expecting jsp to make a call to controller, by sending paramter being searched and render the response back to jsp
enter image description here



enter image description here










share|improve this question
























  • Does your network tab show the call being made? One more thing is that your ajax call is not being used in anyway

    – Edwin Diaz-Mendez
    Mar 22 at 22:50











  • This is what I get "Failed to load resource: the server responded with a status of 500 ()" on hitting the submit button in the inspect element. I am not a UI expert but was working on some POC. Let me know a bit more on what should I be doing.

    – vicky
    Mar 23 at 1:59












  • I am able to make a call to controller but not getting response back rendered, please suggest (i guess it has to do something with return ): $.ajax( type: "GET", dataType : "json", url : "localhost:8080/problems" + problemId, success : function(data) $("#response").html(data); ); return data;

    – vicky
    Mar 23 at 3:28











  • Update your post above with your updated and structured code. Does problem ID get properly set prior to the Ajax call?

    – Edwin Diaz-Mendez
    Mar 23 at 4:53











  • HI Edwin, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

    – vicky
    Mar 23 at 17:36

















0















I have a spring boot application, I want to make a call from the search page(jsp) to controller, fetch the response and update in the jsp by AJAX. Right now on making a submit call, I get nothing. (to add, if I make a rest api call to controller I get a response from db i.e. http://localhost:8080/problems/problemId). Basically I need to know how to combine the response from ui to api. Please suggest if any mapping or bind varibles to be added.



my jsp



<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file = "header.jsp" %>
<div>
<div>
<h1>Lookup from Oracle database</h1>
</div>
<div>
<h2>$message</h2>

<td>Search Category:</td>
<td>
<select name="searchcategories">
<option value="-1">-Select Category-</option>
<option value="problem">problem</option>
<option value="attachment">attachment</option>
<option value="tstt">tstt</option>
</select>
</td>
<td>Entity Id:</td>
<input type="text" name="problemId" id="search_data" class="form-control" placeholder="Search problem no..">
<button type="submit" id="submit_btn" onclick="">Search</button>

</div>
</div>

<%@ include file = "footer.jsp" %>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()

$('#submit_btn').click(function()
var problemId = $('#search_data').val();

$.ajax(
type: "GET",
dataType : "json",
url : "http://localhost:8080/problems/" + problemId,
success : function(data)
/* $("#response").html(data); */
var parsed_data = JSON.parse(data);
console.log(parsed_data.success);


);
return data;
);
);

$("form").submit(function()
alert("Submitted");
);


</script>
</html>


my controller class (gives response when I call directly through rest i.e. http://localhost:8080/problems/problemId):



@RestController
@RequestMapping("/problems")
public class BugController

@Autowired
BugRepository problemRepository;

@GetMapping("/problemId")
public Bug getProblemById(@PathVariable Long problemId)
return problemRepository.findByProblemId(problemId);




Expecting jsp to make a call to controller, by sending paramter being searched and render the response back to jsp
enter image description here



enter image description here










share|improve this question
























  • Does your network tab show the call being made? One more thing is that your ajax call is not being used in anyway

    – Edwin Diaz-Mendez
    Mar 22 at 22:50











  • This is what I get "Failed to load resource: the server responded with a status of 500 ()" on hitting the submit button in the inspect element. I am not a UI expert but was working on some POC. Let me know a bit more on what should I be doing.

    – vicky
    Mar 23 at 1:59












  • I am able to make a call to controller but not getting response back rendered, please suggest (i guess it has to do something with return ): $.ajax( type: "GET", dataType : "json", url : "localhost:8080/problems" + problemId, success : function(data) $("#response").html(data); ); return data;

    – vicky
    Mar 23 at 3:28











  • Update your post above with your updated and structured code. Does problem ID get properly set prior to the Ajax call?

    – Edwin Diaz-Mendez
    Mar 23 at 4:53











  • HI Edwin, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

    – vicky
    Mar 23 at 17:36













0












0








0








I have a spring boot application, I want to make a call from the search page(jsp) to controller, fetch the response and update in the jsp by AJAX. Right now on making a submit call, I get nothing. (to add, if I make a rest api call to controller I get a response from db i.e. http://localhost:8080/problems/problemId). Basically I need to know how to combine the response from ui to api. Please suggest if any mapping or bind varibles to be added.



my jsp



<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file = "header.jsp" %>
<div>
<div>
<h1>Lookup from Oracle database</h1>
</div>
<div>
<h2>$message</h2>

<td>Search Category:</td>
<td>
<select name="searchcategories">
<option value="-1">-Select Category-</option>
<option value="problem">problem</option>
<option value="attachment">attachment</option>
<option value="tstt">tstt</option>
</select>
</td>
<td>Entity Id:</td>
<input type="text" name="problemId" id="search_data" class="form-control" placeholder="Search problem no..">
<button type="submit" id="submit_btn" onclick="">Search</button>

</div>
</div>

<%@ include file = "footer.jsp" %>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()

$('#submit_btn').click(function()
var problemId = $('#search_data').val();

$.ajax(
type: "GET",
dataType : "json",
url : "http://localhost:8080/problems/" + problemId,
success : function(data)
/* $("#response").html(data); */
var parsed_data = JSON.parse(data);
console.log(parsed_data.success);


);
return data;
);
);

$("form").submit(function()
alert("Submitted");
);


</script>
</html>


my controller class (gives response when I call directly through rest i.e. http://localhost:8080/problems/problemId):



@RestController
@RequestMapping("/problems")
public class BugController

@Autowired
BugRepository problemRepository;

@GetMapping("/problemId")
public Bug getProblemById(@PathVariable Long problemId)
return problemRepository.findByProblemId(problemId);




Expecting jsp to make a call to controller, by sending paramter being searched and render the response back to jsp
enter image description here



enter image description here










share|improve this question
















I have a spring boot application, I want to make a call from the search page(jsp) to controller, fetch the response and update in the jsp by AJAX. Right now on making a submit call, I get nothing. (to add, if I make a rest api call to controller I get a response from db i.e. http://localhost:8080/problems/problemId). Basically I need to know how to combine the response from ui to api. Please suggest if any mapping or bind varibles to be added.



my jsp



<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file = "header.jsp" %>
<div>
<div>
<h1>Lookup from Oracle database</h1>
</div>
<div>
<h2>$message</h2>

<td>Search Category:</td>
<td>
<select name="searchcategories">
<option value="-1">-Select Category-</option>
<option value="problem">problem</option>
<option value="attachment">attachment</option>
<option value="tstt">tstt</option>
</select>
</td>
<td>Entity Id:</td>
<input type="text" name="problemId" id="search_data" class="form-control" placeholder="Search problem no..">
<button type="submit" id="submit_btn" onclick="">Search</button>

</div>
</div>

<%@ include file = "footer.jsp" %>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()

$('#submit_btn').click(function()
var problemId = $('#search_data').val();

$.ajax(
type: "GET",
dataType : "json",
url : "http://localhost:8080/problems/" + problemId,
success : function(data)
/* $("#response").html(data); */
var parsed_data = JSON.parse(data);
console.log(parsed_data.success);


);
return data;
);
);

$("form").submit(function()
alert("Submitted");
);


</script>
</html>


my controller class (gives response when I call directly through rest i.e. http://localhost:8080/problems/problemId):



@RestController
@RequestMapping("/problems")
public class BugController

@Autowired
BugRepository problemRepository;

@GetMapping("/problemId")
public Bug getProblemById(@PathVariable Long problemId)
return problemRepository.findByProblemId(problemId);




Expecting jsp to make a call to controller, by sending paramter being searched and render the response back to jsp
enter image description here



enter image description here







javascript java ajax spring-boot spring-mvc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 17:31







vicky

















asked Mar 22 at 22:30









vickyvicky

85




85












  • Does your network tab show the call being made? One more thing is that your ajax call is not being used in anyway

    – Edwin Diaz-Mendez
    Mar 22 at 22:50











  • This is what I get "Failed to load resource: the server responded with a status of 500 ()" on hitting the submit button in the inspect element. I am not a UI expert but was working on some POC. Let me know a bit more on what should I be doing.

    – vicky
    Mar 23 at 1:59












  • I am able to make a call to controller but not getting response back rendered, please suggest (i guess it has to do something with return ): $.ajax( type: "GET", dataType : "json", url : "localhost:8080/problems" + problemId, success : function(data) $("#response").html(data); ); return data;

    – vicky
    Mar 23 at 3:28











  • Update your post above with your updated and structured code. Does problem ID get properly set prior to the Ajax call?

    – Edwin Diaz-Mendez
    Mar 23 at 4:53











  • HI Edwin, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

    – vicky
    Mar 23 at 17:36

















  • Does your network tab show the call being made? One more thing is that your ajax call is not being used in anyway

    – Edwin Diaz-Mendez
    Mar 22 at 22:50











  • This is what I get "Failed to load resource: the server responded with a status of 500 ()" on hitting the submit button in the inspect element. I am not a UI expert but was working on some POC. Let me know a bit more on what should I be doing.

    – vicky
    Mar 23 at 1:59












  • I am able to make a call to controller but not getting response back rendered, please suggest (i guess it has to do something with return ): $.ajax( type: "GET", dataType : "json", url : "localhost:8080/problems" + problemId, success : function(data) $("#response").html(data); ); return data;

    – vicky
    Mar 23 at 3:28











  • Update your post above with your updated and structured code. Does problem ID get properly set prior to the Ajax call?

    – Edwin Diaz-Mendez
    Mar 23 at 4:53











  • HI Edwin, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

    – vicky
    Mar 23 at 17:36
















Does your network tab show the call being made? One more thing is that your ajax call is not being used in anyway

– Edwin Diaz-Mendez
Mar 22 at 22:50





Does your network tab show the call being made? One more thing is that your ajax call is not being used in anyway

– Edwin Diaz-Mendez
Mar 22 at 22:50













This is what I get "Failed to load resource: the server responded with a status of 500 ()" on hitting the submit button in the inspect element. I am not a UI expert but was working on some POC. Let me know a bit more on what should I be doing.

– vicky
Mar 23 at 1:59






This is what I get "Failed to load resource: the server responded with a status of 500 ()" on hitting the submit button in the inspect element. I am not a UI expert but was working on some POC. Let me know a bit more on what should I be doing.

– vicky
Mar 23 at 1:59














I am able to make a call to controller but not getting response back rendered, please suggest (i guess it has to do something with return ): $.ajax( type: "GET", dataType : "json", url : "localhost:8080/problems" + problemId, success : function(data) $("#response").html(data); ); return data;

– vicky
Mar 23 at 3:28





I am able to make a call to controller but not getting response back rendered, please suggest (i guess it has to do something with return ): $.ajax( type: "GET", dataType : "json", url : "localhost:8080/problems" + problemId, success : function(data) $("#response").html(data); ); return data;

– vicky
Mar 23 at 3:28













Update your post above with your updated and structured code. Does problem ID get properly set prior to the Ajax call?

– Edwin Diaz-Mendez
Mar 23 at 4:53





Update your post above with your updated and structured code. Does problem ID get properly set prior to the Ajax call?

– Edwin Diaz-Mendez
Mar 23 at 4:53













HI Edwin, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

– vicky
Mar 23 at 17:36





HI Edwin, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

– vicky
Mar 23 at 17:36












2 Answers
2






active

oldest

votes


















0














It is generally not recommended to have any HTML code outside of the head and body tags, except the doctype and the html wrapper element. This can cause unexpected problems.



The jQuery ajax method parameter object supports the callback properties success, error and complete. At the moment your code seems to start an AJAX request to your backend, but it does not handle the response data.



Here is a link to the jQuery ajax method documentation.






share|improve this answer






























    0














    Your uploaded image shows error status 500(internal server error). This means something wrong with your server side code. Maybe there is a problem with your database find query for example. The exception stacktrace can help you to debug and find server side problem.



    But there is also a client side problem with your ajax code. You should use this pattern for sending rest ajax request to the server:



     $.ajax(
    headers:
    Accept: "application/json; charset=utf-8",
    "Content-Type": "application/json; charset=utf-8"
    ,
    type: "GET",
    dataType : "json",
    url : "http://localhost:8080/problems/" + problemId
    success: function(data)
    //data is in json format. You can log it and use it's properties.

    );





    share|improve this answer























    • HI Hemed, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

      – vicky
      Mar 23 at 17:37












    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308610%2fhow-to-get-an-ajax-response-from-controller-to-jsp%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It is generally not recommended to have any HTML code outside of the head and body tags, except the doctype and the html wrapper element. This can cause unexpected problems.



    The jQuery ajax method parameter object supports the callback properties success, error and complete. At the moment your code seems to start an AJAX request to your backend, but it does not handle the response data.



    Here is a link to the jQuery ajax method documentation.






    share|improve this answer



























      0














      It is generally not recommended to have any HTML code outside of the head and body tags, except the doctype and the html wrapper element. This can cause unexpected problems.



      The jQuery ajax method parameter object supports the callback properties success, error and complete. At the moment your code seems to start an AJAX request to your backend, but it does not handle the response data.



      Here is a link to the jQuery ajax method documentation.






      share|improve this answer

























        0












        0








        0







        It is generally not recommended to have any HTML code outside of the head and body tags, except the doctype and the html wrapper element. This can cause unexpected problems.



        The jQuery ajax method parameter object supports the callback properties success, error and complete. At the moment your code seems to start an AJAX request to your backend, but it does not handle the response data.



        Here is a link to the jQuery ajax method documentation.






        share|improve this answer













        It is generally not recommended to have any HTML code outside of the head and body tags, except the doctype and the html wrapper element. This can cause unexpected problems.



        The jQuery ajax method parameter object supports the callback properties success, error and complete. At the moment your code seems to start an AJAX request to your backend, but it does not handle the response data.



        Here is a link to the jQuery ajax method documentation.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 23:20









        BL4CKYBL4CKY

        134




        134























            0














            Your uploaded image shows error status 500(internal server error). This means something wrong with your server side code. Maybe there is a problem with your database find query for example. The exception stacktrace can help you to debug and find server side problem.



            But there is also a client side problem with your ajax code. You should use this pattern for sending rest ajax request to the server:



             $.ajax(
            headers:
            Accept: "application/json; charset=utf-8",
            "Content-Type": "application/json; charset=utf-8"
            ,
            type: "GET",
            dataType : "json",
            url : "http://localhost:8080/problems/" + problemId
            success: function(data)
            //data is in json format. You can log it and use it's properties.

            );





            share|improve this answer























            • HI Hemed, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

              – vicky
              Mar 23 at 17:37
















            0














            Your uploaded image shows error status 500(internal server error). This means something wrong with your server side code. Maybe there is a problem with your database find query for example. The exception stacktrace can help you to debug and find server side problem.



            But there is also a client side problem with your ajax code. You should use this pattern for sending rest ajax request to the server:



             $.ajax(
            headers:
            Accept: "application/json; charset=utf-8",
            "Content-Type": "application/json; charset=utf-8"
            ,
            type: "GET",
            dataType : "json",
            url : "http://localhost:8080/problems/" + problemId
            success: function(data)
            //data is in json format. You can log it and use it's properties.

            );





            share|improve this answer























            • HI Hemed, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

              – vicky
              Mar 23 at 17:37














            0












            0








            0







            Your uploaded image shows error status 500(internal server error). This means something wrong with your server side code. Maybe there is a problem with your database find query for example. The exception stacktrace can help you to debug and find server side problem.



            But there is also a client side problem with your ajax code. You should use this pattern for sending rest ajax request to the server:



             $.ajax(
            headers:
            Accept: "application/json; charset=utf-8",
            "Content-Type": "application/json; charset=utf-8"
            ,
            type: "GET",
            dataType : "json",
            url : "http://localhost:8080/problems/" + problemId
            success: function(data)
            //data is in json format. You can log it and use it's properties.

            );





            share|improve this answer













            Your uploaded image shows error status 500(internal server error). This means something wrong with your server side code. Maybe there is a problem with your database find query for example. The exception stacktrace can help you to debug and find server side problem.



            But there is also a client side problem with your ajax code. You should use this pattern for sending rest ajax request to the server:



             $.ajax(
            headers:
            Accept: "application/json; charset=utf-8",
            "Content-Type": "application/json; charset=utf-8"
            ,
            type: "GET",
            dataType : "json",
            url : "http://localhost:8080/problems/" + problemId
            success: function(data)
            //data is in json format. You can log it and use it's properties.

            );






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 23 at 9:55









            hamedhamed

            4,96183471




            4,96183471












            • HI Hemed, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

              – vicky
              Mar 23 at 17:37


















            • HI Hemed, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

              – vicky
              Mar 23 at 17:37

















            HI Hemed, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

            – vicky
            Mar 23 at 17:37






            HI Hemed, updated the code in main section, not able to formate by hitting "ENTER" in comments....anyways I am getting some script error, call is going to db and executing hibernating query, I am able to response with postman. Added image of the issue, "ReferenceError: Can't find variable: data" & "SyntaxError: JSON Parse error: Unexpected identifier "object""

            – vicky
            Mar 23 at 17:37


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308610%2fhow-to-get-an-ajax-response-from-controller-to-jsp%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해