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?

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.