jQuery $get error message: Not Found

I am running the following jQuery .get() call from an HTML page:

<div id="fw_results">Results</div>
<script type="text/javascript">
$(document).ready(function() {
    $.get({
        url: "http://fw.localhost:8082/sites/MyPhp/fw.php"
    })
    .success(function(result) {
        $("#fw_results").text(result);
    })
    .error(function(jqXHR, textStatus, errorThrown) {
        $("#fw_results").text("Error: " + textStatus + " " + errorThrown);
    });
});
</script>         

and the fw_result div content is populated with:

Error: error Not Found

When I call fw.localhost:8082/sites/MyPhp/fw.php from my browser, I get the proper result.

How come I get a "Not Found" error message? Is there any way to find more information about the cause of this issue?

Update

From Firebug, I see a call to /sites/MyJS/src/main/webapp/html/%5Bobject%20Object%5D that fails. I don't know what %5Bobject%20Object%5D could be. I am trying to find out.

Update II

For the records, although I though I had gotten rid of the issue, because I moved the code in a Drupal content type instance (yes, this issue happens within a Drupal installation), in fact it appeared again. In the end, it has nothing to do with Drupal.

One just needs to change this:

$.get({
    url: "http://fw.localhost:8082/sites/MyPhp/fw.php"
})

into this:

$.get("http://fw.localhost:8082/sites/MyPhp/fw.php")

to get rid of this error.

Upvotes: 2

Views: 6973

Answers (1)

Bogdan Emil Mariesan
Bogdan Emil Mariesan

Reputation: 5647

well for starters you could try debugging the success callback of the jquery .get using firefox firebug

edit: first of all make sure you download and install firebug from http://getfirebug.com/ after you have in installed, press f12 to activate the firebug console, make sure you go to the scripts tab and click the enable button. A page refresh will be required afterwards.

After the page has reloaded and all scripts are monitored by firebug, you can select from the scripts menu the js file that contains your jquery get, click the js file in the scripts dropdown and put a breakpoint at the success callback (do that by clicking on the left of the line that has the success callback). See if this helps you.

Upvotes: 2

Related Questions