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 in JQuery by gaurav
• 13,460 points
6 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 by rajatha
• 4,940 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,720 points
23,935 views
0 votes
1 answer
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,720 points
6,961 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,720 points
2,501 views
0 votes
1 answer

Microsoft CDN for jQuery or Google CDN?

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

answered Jun 22 in Web Development by rajatha
• 4,940 points
8 views
0 votes
2 answers

Send HTTP request in Java

import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import java.io.IOException; import ...READ MORE

answered Aug 3, 2018 in Java by samarth295
• 2,220 points
861 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Ajax using JQuery in ASP .NET c#

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

answered Jun 15 in JQuery by rajatha
• 4,940 points
9 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 in JQuery by rajatha
• 4,940 points
14 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP