source: sandbox/webservice/restclient_new/exemplo/exemplo.html @ 7818

Revision 7818, 2.0 KB checked in by alexandrecorreia, 11 years ago (diff)

Ticket #2507 - Ajustando o help e criado um exemplo para utilizar o REST.

  • Property svn:executable set to *
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3        <head>
4                <title>.:: ExpressoLivre - API REST ::.</title>
5                <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
6                <meta name="author" content="Equipe Expresso Livre" />
7                <meta name="keywords" content="rest, json, javascript" />
8                <meta name="description" content="Cliente para demonstra&ccedil;&atilde;o do RECURSO REST" />
9                <!--CSS-->
10               
11                <!--JavaScript-->
12                <script type="text/javascript" src="jquery-1.9.0.min.js"></script>
13                <script>
14
15                        function expressoVersion()
16                        {
17                                $.ajax(
18                {
19                        type    : "POST",
20                    url         : "client_rest.php",
21                    data        :
22                    {
23                            serverUrl   : "http://expresso.pr.gov.br/api/rest/ExpressoVersion",
24                            methodType  : "POST"
25                    },
26                    beforeSend: function()
27                    {
28                        // Coloque aqui seu código;
29                        $("#resposta").html("<span style='color:red'>( Aguarde ..... )</span>");
30                                        },
31                    success: function(response)                         
32                    {
33                        //Coloque aqui seu código;
34                        var obj = jQuery.parseJSON(response);
35                       
36                        $("#resposta").html( "Id : " + obj.id + "<br>" +
37                                        "Expresso Vers&atilde;o : " + obj.result.expressoVersion +
38                                        "<br> Vers&atilde;o da API : " + obj.result.apiVersion );
39                    },
40                    error: function(response)
41                    {
42                        console.log("Error : " + response );
43                        }       
44                });
45                        }
46
47                </script>
48        </head>
49        <body>
50
51                <button onclick="expressoVersion();">Clique aqui</button>
52
53                <div style="font:12pt Verdana, sans, arial; margin:10px;">
54                       
55                        <label>Resposta : </label>
56
57                        <div id="resposta" style="padding:10px;"></div>
58                                                       
59                </div>
60        </body>
61</html>
62               
Note: See TracBrowser for help on using the repository browser.