JSFiddle - React, Tailwind, and code Playground

by ltfleming

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://code.angularjs.org/1.5.8/angular.js"></script>

<div ng-controller="TestCtrl">
  <br>
  <input type="url" maxlength="50" size="50" ng-model="sendToLocation.url">
  <br>
  <br>
  <button id="sendbutton" type="button" ng-click="sendToLocation()">Send</button>
</div>

JavaScript

var app = angular.module('myApp', []);
app.controller('TestCtrl', function($scope, $http) {
  $scope.sendToLocation = function() {
    var jsondata = {
      "id": 1,
      "name": "Test Name",
      "price": 100,
      "city": "XYZ"
    };

    $http.post($scope.sendToLocation.url, jsondata, {}).then(
      function(response) {
        alert("yes, you have posted the data !");
      },
      function(error) {

      });
    //alert(JSON.stringify(jsondata));//gives the above json
  };

});