php - How to add string to file at server side using AJAX -
i trying save values taken webix textarea file @ server, no luck now. eaqsily 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 ) ); ?>
but don't know how ajax. need - take value textarea, insert (for e.g.) 6th string of data/data.php file.
this code:
<!doctype html> <html> <head> <title>loading 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 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 " + $$('textarea').getvalue()); } }, "labelposition": "top" } ] }); }); </script> </body> </html>
so want once click passs button, takes values textarea , save in 6th string of data/data.php file. extract value textarea )))))
data/data.php looks this:
<?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 connect mysql"); echo "connected mysql<br>"; $data = new jsondataconnector($conn,$dbtype); $data->render_sql("select site_id, 3g_site_id master_tracker_db.master_tracker site_id '%abk000%'", "", "site_id, 3g_site_id"); ?>
Comments
Post a Comment