Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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