Jump to content

Problems with the server Response Format


phpknight

Recommended Posts

Hi,

 

I have figured out that AJAX can send the response back as XML or just text.  I was having some issues until I realized that it would be easier to get the responseText and put it in the DIV.  Unfortunately, it appears that the responseText is not exactly what I send back, rather it is what I send with everything encoded for HTML special characters!  So, the source code just appears right on the page instead of what I want.  How do I get around this?

 

 

Here is the solution I have found.  Somebody please let me know if I should be doing something else.  The books I have do not cover any responses except xml.  Instead of xml, I sent this as the header: header('Content-Type: text/html');

 

Then, it works great.  Is there any reason I might not want to do it this way?

Right, that is what I want.  The problem was when I was using the example from the book, it sent xml headers.  So, when I tried to get the responseText property, it was giving me the code with all the tags written out as special characters, so then the actual source code showed up on the page--like <div>...</div> instead of a box.  I'm not sure why it was converting all the characters, though.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.