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,073 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,640 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,880 points
41,496 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,880 points
1,356 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,880 points
17,223 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,880 points
6,361 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,640 points
452 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
6,244 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,010 points
264 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
669 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,640 points
3,368 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,640 points
13,004 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