Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no respond when click button to get json data from url in table

Status
Not open for further replies.

ahm1985

Programmer
Dec 6, 2012
138
EG
I have url i need to display FirstName,Id,Salary in table by click button using jquery
when click button not give me any result and give me two message
I try more time but it give me error
submit handler has fired this is normal to check
error error not found this message show to me
my code as below
Code:
[code]

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>

    <script src="~/Scripts/jquery-1.10.2.js"></script>
    <script>
        $(function () {
            $('#btn').click(function () {
               alert("submit handler has fired");
                $.ajax({
                   // type: 'POST',
                    url: '[URL unfurl="true"]www.DevuEgypt.com/api/employees',[/URL]
                    data:{},
                    dataType: 'json',

                    success: function (data) {
                        $.each(data, function (index, value) {
                           var row = $("<tr><td>" + value.FirstName + "</td><td>" + value.Id + "</td><td>" + value.Salary + "</td></tr>");
                          $("#myData").append(row);
                         });
                      
                    },
                   error: function (jqXHR, textStatus, errorThrown) {
                        alert('error: ' + textStatus + ': ' + errorThrown);
                   }
                });
                //return false;//suppress natural form submission
            });
        });
    </script>
</head>
<body>
    <div> 
        <input type="button" value="GetData" id="btn" />
        <table id="myData"></table>
    </div>
</body>
</html>
[/code]
 
The URL you posted is only an XML file with no javascript to do anything at all.

And this;
JavaScript:
<script src="~/Scripts/jquery-1.10.2.js"></script>
Will not 'work' on a remote server as '~' refers to the 'home' directory of the logged in user and on a web server, there is no 'logged in user' to have a 'home directory'.



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top