JQuery Encode URL

Discussion in 'jQuery' started by Infranight, Nov 25, 2010.

  1. #1
    I have the following code snippet:

    function autosave() 
    { 
        setTimeout("autosave()", 15000); 
     
        var did = $("#did").val(); 
        var content = $('.nicEdit-frame').contents().find('#nicEditContent').html();
     
        if (content.length > 0) 
        { 
            $.ajax( 
            { 
                type: "POST", 
                url: "inc/autosave.class.php", 
                data:  "did=" + did + "&content=" + content,
    	            contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
                cache: false, 
                success: function(message) 
                { 
                    $("#message").empty().append(message); 
                }
            }); 
        } 
    }
    HTML:
    What this does is takes what is in a textarea and sends it over to the autosave.class.php, which sends it off to the MySQL database.
    The problem is that the data ends up in the database cut off, showing only the first few sentences of it; often cutting off at the quotation mark.
    I am positive that this isn't the PHP to MySQL issue (already tested that), it's the AJAX/JQuery data to PHP part.
    Is it the lack of serializing/encoding? If so, how would I fix it?
     
    Infranight, Nov 25, 2010 IP
  2. Infranight

    Infranight Member

    Messages:
    319
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Never mind, I solved it - it was a matter of encoding &s.
     
    Infranight, Nov 25, 2010 IP
  3. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #3
    & should be &, no?
     
    CSM, Nov 26, 2010 IP