Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/jQuery passing carriage returns seems to bust jQuery
    primarykey
    data
    text
    <p>jQuery front end, php/mySql back end... I'm passing in a text area - scrubbing it for htmlspecialchars() and doing mysql_real_escape_string() everything goes in fine, but when I try to pull it out and 'edit' it in the same form, the jQuery ceases to work - to the point where the modal window wont even pop up...</p> <p>everything works as expected - UNTIL i put a carriage return in the text area....</p> <p>I'm using this js to populate the form fields...</p> <pre><code>// loop and populate - must have matching field names to key names $.each( data, function( key, value ) { $( '#' + key ).val( value ); }); </code></pre> <p>I'm using a JSON call to populate the edit form...and the JSON is coming back with the carriage return... so the issue isn't on the back end...</p> <p>JSON</p> <pre><code>{ "id":"12", "for_customer_id":"18","customer_id":"20", "engagement_label":"", "part_number":"asdwew", "part_description":"wwe wew wew", "defect_description":" asd asd asd asd as ", "notification_date":"01/01/2013", "notification_timeCTZ":"3pm", "emp_training_on_file":"Yes", "work_instructions":"hhhllkjijj asd asd a sd a new row", "supervisor_id":"25", "start_date":"", "end_date":"", "date_completed":"" } </code></pre> <p>"work instructions" - where it says 'new row' is right after CR.</p> <p>what am I missing??? THX</p> <p>I may have chosen the "wrong" way to do this - but I decided to do it on the server in PHP... however even though I'm replacing chrs correctly, JSON still seems to have a problem consuming.... where can I find the needed info for JSON and carriage returns... HELP! thx.</p> <p>MY PHP putting to the db is scrubbed...based on some reading - I've tried 1,2 and 3 slashes () (this is a function to format the string before it gets to the SQL statement)</p> <pre><code>function parse( $text ){ $parsedText = str_replace( chr(10), '', $parsedText ); return str_replace( chr(13), '\\\n', $parsedText ); } </code></pre> <p>MY PHP coming out - again based on some reading... I'm making my own JSON due to a specific data structure needed... (this is a function to format the string before it gets put in the JSON)</p> <pre><code>function parseString( $string ) {//function to make JSON CR and the like suitable for comsumption $string = str_replace( '\\', '\\\\', $string ); $string = str_replace( '/', '\\/', $string ); $string = str_replace( '"', '\\'.'"', $string ); $string = str_replace( '\b', '\\b', $string ); $string = str_replace( '\t', '\\t', $string ); $string = str_replace( '\n', '\\n', $string ); $string = str_replace( '\f', '\\f', $string ); $string = str_replace( '\r', '\\r', $string ); $string = str_replace( '\u', '\\u', $string ); return $string; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload