javascript - jquery textarea get error if i am using space between text -


in code if write string worked if write whitespace or spacial character or ' , "" following code give me error syntex error how can fix it. jquery cause error js script

<script type="text/javascript">     $(document).ready(function() {         $('#content').keyup(function() {             content = $('#content').val();             $('#editor-result').html('&nbsp;').load( 'http://127.0.0.1:8000/ask/req_pass/?content=' + content);         });     }); </script> 

html code:

<div class="row"><label for="title" class="col-md-1">title:</label><input class="col-md-8" type="text" name="title" id="title"></div>     <div class="row" style="padding-top: 1em"><textarea class="form-control" rows="12" id="content" name="content"></textarea>     </div>         <div class="row">             <div class="col-md-12" id="editor-result" ></div>         </div> </div> 

it's because you're attempting pass content of text field "content" part of query string in url ('http://127.0.0.1:8000/ask/req_pass/?content=' + content) characters not allowed. if absolutely must need escape characters in order them allowed in querystring, better off using .ajax() function instead.

$.ajax({   url: "http://127.0.0.1:8000/ask/req_pass",   type: "post",   data: {content : content} }); 

also - want make call server on every keypress in text area? right that's happen. can preview of written doing this:

$(document).ready(function() { $('#content').keyup(function() {         content = $('#content').val();         $('#editor-result').html('&nbsp;' + content);     }); }); 

...removing call server entirely.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -