Load reports success but does not work..
Hello!
I have a problem that is driving me insane. Currently I am working in VS2008 with an MVC2 project and I am using jQuery 1.4.1. A very easy task has somehow become utterly complex and I don´t know what I might be missing.
I am trying to use the load() function (
http://api.jquery.com/load/ ) to load remote content into a div but I cannot get it to work. With a callback function I have determined that load does not return an error, but a success. Still, noting is displayed in the div. I´ve gone so far that I´ve downloaded demo examples and mysteriously I could then load only the same file I was in; index.html could load('index.html') where as no other urls could be loaded. I´m starting to think that this might be computer/system-specific. Tried several browsers as well (including IE, FF, Opera, Iron).
Markup link to function:
- <span onclick="loadContent();">n</span>
Code:
- function loadContent() {
- var url = 'http://www.myserver.org/index.php';
- $("#content").fadeIn().load(url, function(response, status, xhr) {
- if (status == "error") {
- var msg = "Sorry but there was an error: ";
- $("#content").html(msg + xhr.status + " " + xhr.statusText);
- }
- else {
- $("#content").append(status);
- }
- });
- $("#content").css('z-index', '1000');
- }
Please observe that I have already tried without the ELSE-clause. I simply added it to see what the status message would be, and the status message displayed is 'success', nothing else is displayed.
Previously I had a simplified version of this code:
- function loadContent() {
- var url = 'http://www.myserver.org/index.php';
- $("#content").load(url);
- $("#content").css('z-index', '1000');
- $("#content").show();
- }
The result was the same with this code, nothing displayed.
Anybody?