我正在尝试将从webix textarea获取的值保存到服务器上的文件,但现在没有运气。 我可以用php完成它:
$filename = getcwd() . "/test.txt";
echo $filename;
$line_i_am_looking_for = 5;
$lines = file( $filename , FILE_IGNORE_NEW_LINES );
$lines[$line_i_am_looking_for] = '6my modified line';
file_put_contents( $filename , implode( "\n", $lines ) );
?>
但我不知道如何用AJAX做到这一点。 我需要的是 - 从textarea获取值,将其插入(例如)第6个数据/ data.php文件串。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>Loading from DB</title>
<link rel="stylesheet" href="codebase/webix.css" type="text/css">
<script src="codebase/webix.js" type="text/javascript"></script>
</head>
<body>
<?php
$filename = getcwd() . "/test.txt";
echo $filename;
$line_i_am_looking_for = 5;
$lines = file( $filename , FILE_IGNORE_NEW_LINES );
$lines[$line_i_am_looking_for] = '6my modified line';
file_put_contents( $filename , implode( "\n", $lines ) );
?>
<div class='header_comment'>Test Button</div>
<div id="testB" style='height:600px'></div>
<hr>
<script type="text/javascript" charset="utf-8">
webix.ready(function() {
gridb = webix.ui({
container: "testB",
"view": "form",
"elements": [
{
"view": "textarea",
"name": "woNumber",
"id": "textarea",
"label": "",
"width": 300,
"height": 200,
"options": [
"onViewResize"
],
"value": "",
"placeholder": "WO number (separate with comma if several)",
"labelPosition": "top"
},
{
"view": "button",
"name": "getWODetails",
"label": "",
"value": "Submit",
"options": [
"autowidth:true"
],
on: {
onItemClick: function(id) {
webix.message("Sikim BLEAT'!!!");
}
},
"labelPosition": "top"
},
{
"view": "button",
"id": "button1",
"name": "getWODetails",
"label": "",
"value": "Passss",
"options": [
"autowidth:true"
],
on: {
onItemClick: function() {
webix.message("Values of textarea is " + $$('textarea').getValue());
}
},
"labelPosition": "top"
}
]
});
});
</script>
</body>
</html>
所以我想要做的是,一旦我点击Passs按钮,它会从textarea获取值并将其保存在第6个data / data.php文件中。我现在所能做的就是从textarea中提取价值)))))
data / data.php看起来像这样:
<?php
require_once("../samples/common/connector/data_connector.php");
//!connector
$dbtype = "MySQL";
$username = "roman";
$password = "Pass";
$hostname = "111.111.111.111";
$conn = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
$data = new JSONDataConnector($conn,$dbtype);
$data->render_sql("SELECT SITE_ID, 3G_SITE_ID
FROM MASTER_TRACKER_DB.MASTER_TRACKER
WHERE SITE_ID LIKE '%ABK000%'", "", "SITE_ID, 3G_SITE_ID");
?>