SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member marianoross's Avatar
    Join Date
    Feb 2013
    Location
    Ladispoli
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Jquery and $.post for write on the file

    Hi,
    I downloaded a sample to write to a file that is entered in an input field, using the $. Jquery post, but it does not work. Can you give me some working example.
    thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi marianoross,

    Check the below code:

    var fieldVal = document.getElementById("txtfield");

    $.post('test.php', {fieldtxt: trim(fieldVal.value)}, function(data) {

    //trim - This is a function written by me for trimming the string
    //Write a code in test.php which will accept the passed value and write that data into an file.

    });

    I hope above code might help you.
    PHP Programming Itís more than just writing code

  3. #3
    SitePoint Member marianoross's Avatar
    Join Date
    Feb 2013
    Location
    Ladispoli
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    I found the following code:
    $.post('save',
    {id: $editable.attr('id'), value: contents},
    function(data) {
    $editable
    .removeClass('active-inline')
    .contents()
    .replaceWith(contents);
    });
    where "save" is the file, the method post will not write into file directly, but will I need a function in php or java o c#?
    thanks

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2011
    Location
    Kolding, Denmark
    Posts
    108
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Yes, 'save' should be the script on your server which handles writing to file. jQuery itself can't write to the file on server as it's executed in browser.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •