tonelm54
asked on
.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:-
if the retHTML is initially returned from the ajax request as:-
After it is injected into divFolder, it now equals:-
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
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);
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
jQuery will not do that.
ASKER
So the ajax Im using is:-
Does anyone have any ideas on how to turn this off?
$.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);
}
});
Does anyone have any ideas on how to turn this off?
ASKER
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!
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does anyone know how to switch it off?