Jquery Ajax GET method nothing happend when success

0 votes
I have a RESTful web service which runs on Glassfish Application Server. When I invoke the web services with /GET HTTP method on cURL, stored entries are fetched to console. I want to make a jQuery REST client - when I click the button, it must alert me to the returned JSON or XML entries. But in success method, nothing happened.
Jun 21, 2022 in JQuery by gaurav
• 23,260 points
2,427 views

1 answer to this question.

0 votes

this should help you debug the issue

$('#rename').click(function () {
    //alert( $(this).closest('td').prev().prev().text());
    var name = prompt('enter the new name');
    if (name) $.ajax({
        url: url() + '/rename',
        type: 'POST',
        data: { value: name,
            id: $(this).closest('tr').find('td :first').attr('value')
        },
        success: function (result) {
            alert('success');
            if (result.content == 1) {//location.reload();
                alert(name);
                //$(this).closest('td').prev().prev().text(name);
            }
        },
        error: function () {
            alert('error');
        }
    })
});

basically added a couple of extra points.

  1. How do you know success is happening and result.context just isn't equal to 1, so added the alert('success');
  2. How do you know it's resturning success at all? Added

    error: function () { alert('error'); }

  3. you were missing a ; at the end. :)

answered Jun 21, 2022 by rajatha
• 7,680 points

Related Questions In JQuery

0 votes
1 answer

How to pass parameters in GET requests with jQuery?

Hello, Here is the syntax using jQuery $.get $.get(url, data, ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
43,986 views
0 votes
1 answer

JQuery Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

Hello @kartik, Try this - it works for ...READ MORE

answered May 29, 2020 in JQuery by Niroj
• 82,840 points
2,063 views
0 votes
1 answer

How to Get Currently Selected Tab Index In jQuery UI Tabs?

Hello @kartik, If you need to get the ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,840 points
18,800 views
0 votes
1 answer

How to pass parameters in GET requests with jQuery?

Hello @kartik, Use data option of ajax. You ...READ MORE

answered Oct 5, 2020 in JQuery by Niroj
• 82,840 points
7,084 views
0 votes
1 answer

Microsoft CDN for jQuery or Google CDN?

You should absolutely use the Google CDN ...READ MORE

answered Jun 22, 2022 in Web Development by rajatha
• 7,680 points
682 views
0 votes
1 answer

how to use json file in html code?

<html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script> <script> ...READ MORE

answered Aug 8, 2022 in HTML by Vikas
7,302 views
0 votes
0 answers

How to send a GET request from PHP?

I intend to use PHP to fulfil ...READ MORE

Aug 7, 2022 in PHP by Kithuzzz
• 38,000 points
486 views
0 votes
0 answers

JQUERY: Getting JSON Data from URL

I am trying to use $.getJSON() to get JSON ...READ MORE

Aug 12, 2022 in Web Development by gaurav
• 23,260 points
959 views
0 votes
1 answer

Ajax using JQuery in ASP .NET c#

jQuery Ajax in ASP.Net $.ajax({      & ...READ MORE

answered Jun 15, 2022 in JQuery by rajatha
• 7,680 points
4,098 views
0 votes
1 answer

How to reset a form using jQuery with .reset() method

<input type="reset"> Syntax for reset(): formObject.reset() Syntax to convert ...READ MORE

answered Jun 16, 2022 in JQuery by rajatha
• 7,680 points
15,801 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP