Jump to content

Recommended Posts

Hi ! I am having a heck of a time sending data back in responseText. First of all, I am not actually sure how my data is being sent back into responseText - it is the result of me using a jquery plugin called iframetransport which seeks to transport file inputs across an iframe for ajax like form submission. Anyway, I am echoing back data from PHP like so

 

echo json_encode(array("rowData"=> '<div class = "row" data-id = "'.$row['id'].'" >
         <div class = "row"><img src="data:image/jpeg;base64,'.base64_encode( $row['blob'] ).'"/></div>
               <div class = "container">
          <div class = "name"><p>'.$row['name'] .'</p></div>
      </div>
   </div>'));
 
I know that this data is valid in normal ajax $.posts because I also have form submission without the iframetransport, and it returns the exact same data with no issue. However, when the above data makes its way into responseText it looks like this on the client side:
 
"{"rowData":"\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tasdasd<\/p><\/div>\n\t\t\t\t\t\t\t<\/p><\/div>\n\t\t\t\t\t\t\t<\/p><\/div>\n\t\t\t\t\t\t\t1<\/p><\/div>\n\t\t\t\t\t\t\t<\/p><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>"}"
 
All my divs and elements are replaced with \t or they are not making it into the response.
 
Also when I return blobs like this (this is even worse) I get a 414 (Request-URI Too Large)
 
Any help is appreciated. This is the plugin http://cmlenz.github.io/jquery-iframe-transport/ if interested. 

i tryed your code i removed all the line brakes from the code and i have this

$d = array("rowData"=> '<div class = "row" data-id = "'.$row['id'].'" ><div class = "row"><img src="data:image/jpeg;base64,'.base64_encode( $row['blob'] ).'"/></div><div class = "container"><div class = "name"><p>'.$row['name'] .'</p></div></div></div>');
echo json_encode($d);

and the output looks like 

 

 

  {"rowData":"<div class = \"row\" data-id = \"test2\" ><div class = \"row\"><img src=\"data:image\/jpeg;base64,ZXRzdDE=\"\/><\/div><div class = \"container\"><div class = \"name\"><p>test3<\/p><\/div><\/div><\/div>"}
Edited by blacknight
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.