Problem with sending posts via Ajax

2

I am creating a chat with websocket , when I send a message it saves the message in the database. This is the example of how it sends the message post

ButtheproblemiswhenIsendajavascriptfunction(I'mtryingtodeletejavascriptinjectionininputdamensagem).Followtheprintofhowyouaresending(Allbugged)andonlysavesthebeginningofthemessage:

Can anyone solve this problem for me? Here's the code in Jsfiddle of how I'm doing: link (see the requests sent via XHR to see the post being bogged).

    
asked by anonymous 07.06.2015 / 04:59

1 answer

2

You can use encodeURIComponent in javascript:

data: 'acao=' + encodeURIComponent(input),

When you receive the date on the server you should make a decode in PHP:

urldecode()
    
08.06.2015 / 00:26