• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

.html is not true return

This is quite strange, and I cannot find any documentation to swith it off.

I have some simple code, which fires an AJAX request, and return the result in as retHtml:-
                                          
	alert(retHtml);
	$("#divFolder).html(retHtml);
	alert($("#divFolder).html);

Open in new window


if the retHTML is initially returned from the ajax request as:-
<img src="openFolder.jpg" />

After it is injected into divFolder, it now equals:-
<img src="http://localhost/openFolder.jpg" />

Which is great, but the I need my code to return exactly what is returned, not phase it.

Does anyone know how to stop jQuery modifying my code?

Thank you
0
tonelm54
Asked:
tonelm54
  • 3
  • 2
1 Solution
 
tonelm54Author Commented:
Right, Ive found out that apparently jQuery "sanitizes" the data returned by the AJAX request:-

dataFilter(data, type) Function
A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter.

Does anyone know how to switch it off?
0
 
leakim971PluritechnicianCommented:
jQuery will not do that.
0
 
tonelm54Author Commented:
So the ajax Im using is:-

						$.ajax({
							type: 'GET',
							url: 'viewTree.php',
							dataType: 'html',
							dataFilter: function(data, dataType) {
								return data;
								},
							success: function(retHtml, textStatus) {
								//alert(retHtml);
								$("#divFolder).html(retHtml);
								//alert($("#divFolder).html);
								},
							error: function (xhr, textStatus, errorThrown) {
								$("#error").html("Failed - " + errorThrown ? errorThrown : xhr.status);
								}
							});

Open in new window


Does anyone have any ideas on how to turn this off?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
tonelm54Author Commented:
leakim971: Sorry, I missed your reply before posting my last comment, according to the ajax documentation on the jQuery website it does sanatise the data, which Im assuming is what its doing. I could be wrong though!
0
 
leakim971PluritechnicianCommented:
A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter.

It mean YOU can use it sanitize the data.

Anyway, if you load the image <img src="openFolder.jpg" /> from http://localhost, the URL of the image is : http://localhost/openFolder.jpg
if you load the same content/data, I mean <img src="openFolder.jpg" /> it in your page from http://localhost/images the url of the image is : http://localhost/images/openFolder.jpg

if you don't want your image follow the path of the current page, prefix it's path with /

check this article for example : http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm


0
 
haloexpertsexchangeCommented:
could it have anything to do with the fact that you have not closed out your selector " here->      $("#divFolder).html(retHtml); should be       $("#divFolder").html(retHtml);

When I have used jquery get ajax calls, it does not do any special sanitization to my img src that is returned.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now