JSFiddle - React, Tailwind, and code Playground

by yangchenyun

HTML

<div id="addComments" align="center" style="width:300px; height:300px;">
    <form id="myForm">
<textarea  id="Textarea1" style="width:300px; height:300px;"></textarea>
   <button class="submit">Submit</button>
   <button>Cancel</button>
    </form>

JavaScript

$('#myForm').submit(addMethod);

function addMethod() {

    try {
        var _settings = {
            ratedObjectId: 2,
            tenantId: 34,
        };
        // var div = document.getElementById('addComments');
        // div.style.visibility = "visible";
        // var textArea = document.getElementById('Textarea1');
        // textArea.style.visibility = "visible";
        var mashupId = _settings.ratedObjectId;
        var tenantId = _settings.tenantId;
        
        var comments = 'This is added text';
        
        alert(comments);
        
        var user = {
            "Id": 2007,
            "FirstName": "Ufone",
            "LastName": "",
            "EmailAddress": "[email protected]"
        };

        var ratingInfo = {

            "Id": 0,

            "TenantId": tenantId,

            "UserId": user.Id,

            "FirstName": user.FirstName,

            "LastName": user.LastName,

            "Rating": 0,

            "EmailAddress": user.EmailAddress,

            "Comments": comments,

            "RatedObjectTypeInfo": {
                "Id": 2
            },

            "RatingTypeInfo": {
                "Id": 1
            },

            "MashupRatingInfo": {
                "MashupMetaInfoId": mashupId
            },

            "RatedObjectId": mashupId,

            "TotalCount": 0

        };
        
        var url = "http://services.farooq.tv/RatingInfoManagementService/RatingInfoManagementService.svc/ajax/AddRating";

        $.ajax({
            type: "POST",
            url: url,
            data: JSON.stringify(ratingInfo),
            contentType: "application/json",
            timeout: 5000,
            success: function(d) {
                if (d.comments === true) {
                    console.log(d);
                    alert("Success");
                }
              },

            error: function(xhr, ajaxOptions, thrownError) {
                    console.log(xhr);
                }

  ...