www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Saving content of textarea. PHP/Javascript editor

Threaded View

  1. #1
    Join Date
    Sep 2008
    Posts
    61

    resolved [RESOLVED] Saving content of textarea. PHP/Javascript editor

    Hi!

    I am using editArea for a project of mine. And I am using two buttons to save the content of the editArea. One "Save" (which will go directly through form, to php, and then be redirected to another page). And one "Apply" which will save using an AJAX function, like this :

    Code:
    function saveContent() {
    
                    var table = "<?php echo $table; ?>";
                    var type = "<?php echo $type; ?>";
                    var id = "<?php echo $id; ?>";
                    var name = "<?php echo $name; ?>";
    
                    var parameters = "contents=" + editAreaLoader.getValue("editArea1");
                    parameters = parameters + "&table=" + table;
                    parameters = parameters + "&type=" + type;
                    parameters = parameters + "&id=" + id;
                    parameters = parameters + "&name=" + name;
                    var xmlHttpReq = null;
                    // Mozilla/Safari
                    if (window.XMLHttpRequest) {
                            xmlHttpReq = new XMLHttpRequest();
                    }
                    // IE
                    else if (window.ActiveXObject) {
                            xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    xmlHttpReq.open('POST', 'save.php?ajax&edit');
                    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttpReq.setRequestHeader("Content-length", parameters.length);
                    xmlHttpReq.setRequestHeader("Connection", "close");
                    xmlHttpReq.onreadystatechange = function() {
                            if (xmlHttpReq.readyState == 4) {
                                alert("Saved!");
                            }
                    };
                    xmlHttpReq.send(parameters);
                 }
    And the "Save" button that will save the data using form -> php works perfectly. But when I press the "Apply" (AJAX function) it will loose characters like \ / + && and similar.

    So the code
    Code:
    if(somebool && anotherbool) function();
    will become
    Code:
    if(somebool anotherbool) function();
    Which clearly will not work...

    What can I do to make it work properly?

    Thanks,
    Artheus
    Last edited by artheus; 03-17-2010 at 05:00 AM. Reason: additional information

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles