Alvin Alvin - 1 year ago 121
Javascript Question

Using REST API and send POST request

POST localhost:5000/registrar

"enrollId": "jim",
"enrollSecret": "6avZQLwcUe9b"

How do I use this in a javascript file? Do I use JSON or JQuery? And how do I invoke the request function in .html?

Answer Source

Use jquery for this:

<script src=""></script>

And call function


    $.post('localhost:5000/registrar', {
      "enrollId": "jim",
      "enrollSecret": "6avZQLwcUe9b"
    }, function(serverResponse){

    //do what you want with server response


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download