views:

6

answers:

0

I have been dealing with this one for a few hours and am baffled at the work around:

I have a page that contains a form which sends a .post and retrieves html to replace a certain table. It works fine with a string with no crlf, but if there is a crlf, it does not replace the html in the table... Of course, it silently errors.

I have tried a json_encode, which has the same effect. I had some success with addslashes, except that for urls it creates a double slash like this: \. Returning this value is messing up either javascript, jquery, or jason.

$(document).ready(function() {
    $('#verify form').submit(function() {
        $.post('/index.php/processor/verify', $(this).serialize(), function(data) {

          $.each(data, function(entryIndex, entry) {
                $('#tc').html(entry['definition']);
                //$('#msg').html(entry['msg']);
              });
        }, 'json');
        return false;
    });
    return false;
});

The processor script essentially returns a value like such:

[
  {
    "definition": "'.json_encode(addslashes("<form action=\"http:\/\/localhost\/index.php\" method=\"post\"><input type=hidden name=tc_id value='502'><input type=\"submit\" name=\"verify\" value=\"verify\" verify \/><\/form>")).'",
    "msg": "Success.",

  }
]

Any thoughts on how I can replace html on my page through a .post where I can get an array back would be appreciated.

Thanks