1
這是我的鏈接通過我的div可見如何在一個文本中添加文本,並將其發佈到服務
<a href="javascript:addMethod()">+ Create a new comment</a>
和方法被調用它是如下
function addMethod()
{
try {
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 = null;
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);
}
});
}
catch (err)
{
alert(err);
}
}
這是我的div和它裏面是一個文本區域和按鈕
<div id="addComments" align="center" style="width:300px; height:300px; visibility:hidden">
<textarea id="Textarea1" style="width:300px; height:300px; visibility:hidden"> </textarea>
<button>Submit</button>
<button>Cancel</button>
</div>
我想在文本區域添加文本,並將其保存在一個變量後提交按下按鈕
<button>Submit</button>
,並在其中我想存儲文本區域的文本變量是
var comments = null;
請幫助即時通訊新編程......