#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2

    Write into a text file using jQuery


    The function to read from a text file and display it into e textfield works, but the function to write into a text file doesn't work!

    this are the functions :
    Code:
    \$(document).ready(function() {
     \$("#readFile").click(function() {
        \$.get('read.txt', function(data) {
          \$("#container").val(data);
        }, 'text');
     });
    });
    
    \$(document).ready(function() {
     \$("#writeFile").click(function() {
        \$.post('write.txt', function(data) {
          \$("#container").val(data);
        }, 'text');
     });
    });
    what may be the problem?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,998
    Rep Power
    9397
    You can't write to a file over the Internet. There has to be something running on the server you're connecting to that makes the changes you tell it to make.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2
    I am using Padre and programming in Perl
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2
    that's the code:
    Code:
    my  $script=qq{
         
    \$(document).ready(function() {
     \$("#readFile").click(function() {
        \$.get('read.txt', function(data) {
          \$("#container").val(data);
        }, 'text');
     });
    });
    
    
    \$(document).ready(function() {
     \$("#writeFile").click(function() { 
        \$.post('write.txt', function(data) {
          \$("#cont").val(data);
        }, 'text');
     });
    });
    
    };
          
    my $q= new CGI;
    print $q -> header;
    print $q->start_html(
    -title=>"Read a File",
    -style  => {-src =>'css/ui-lightness/jquery-ui-1.10.3.custom.css" rel="stylesheet'},
         -script => [
            {-src =>'js/jquery-1.9.1.js'}, 
            {-src =>'js/jquery-ui-1.10.3.custom.js'
                    
            }, 
          ],   
    );
    print $q->start_form;
    print $q->textfield(
        -style=>'font-family:verdana;width:300px;font-size:13px',
        -id=>'container',
        -value => '', 
        
    );
     print $q->button(
            -id       => 'readFile',
            -name     => 'submit_form',
            -value    => 'Read',
        );
    
    print $q->textfield(
        -style=>'font-family:verdana;width:300px;font-size:13px',
        -id=>'cont',
        -value => '', 
        
    );
    
     print $q->submit(
            -id       => 'writeFile',
            -name     => 'submit_form',
            -value    => 'Write',
    
        );
    print $q->script($script); 
    print $q->end_html;
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2
    Like what? please take a look at my previously comments i have put my code in ther! Thank you

IMN logo majestic logo threadwatch logo seochat tools logo