如果我試圖在textarea中發送Html數據代碼失敗。警報工作,直到用戶名數據正確,但Ajax不發送我的數據到Php服務器。如何使用ajax獲取文本區域數據(在文本區域中的Html文件)我需要發送數據到Php? Ajax不發送我的文本區域數據?
的Javascript
var username=document.getElementById("my_text").value;
if(username){
$.ajax({
type: 'post',
url: 'checkdata.php?username=username',
data: {
username:username,
},
success: function (response){
$('#name_status').html(response);
if(response=="OK"){
return true;
}
else{
return false;
}
}
});
的Html
<textarea id="my_text" >
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
</textarea>
console.log show username有一個值? – clearshot66
先生,我將Html整個文件發送到Ajax。所有數據進入用戶名如果條件。之後,不工作 –
我的問題是Ajax不工作,數據不發送到PHP服務器。在ajax失敗 –