jQuery ajax中的井字字符(#)

in below code; it gets a content of a "div" includes html codes, and it saves at ajsave.php. But when div html contents include "#" character, data is shorted after "#" like this:

$.ajax({ 
    type: "GET", 
    url: "ajsave.php", 
    data: "usr="+id+"&divcontent="+cont, 
    success: function(msg){
        $("#result").html(msg); 
}});

This is because the # is to define the anchor in the page so it is removed... I would suggest you use POST instead of GET, it will correct your problem and prevent some more. If you still want to have it in GET, do this:

cont = cont.replace("#","%22");

In a URL the # character is used to designate an anchor - part of the page that you want to move the page to - so is ignored by your web server. In order to fix this, you'll need to escape it on the client-side (in your JavaScript code) using the encodeURIComponent() function, and then unescape it on the server.