3

When I run the following XmlHttpRequest

$.get('../entries/find_most_recent',
    {name:$("#name").val()}, 
    function(data) {
        console.log("data");
    });

The result can be seen in this Firebug screenshot:

alt text

But when I remove the quotes from console.log("data"), like so:

$.get('../entries/find_most_recent',
    {name:$("#name").val()}, 
    function(data) {
        console.log(data);
    });

Nothing comes up in Firebug. The response is just a string, as can be seen in the screenshot above. How do I access it? Thanks for reading.

4
  • 1
    If I get you right, the Response tab is empty if you remove the quotes? Sounds pretty much impossible, since the point where you receive the response is way before any javascript comes into play. Commented Jul 27, 2010 at 11:13
  • Agreed. What you're doing with console.log("data"); is logging the string data (which correctly appears in the bottom of the screen shot). The actual data or the request is unrelated. Could this be a Firebug bug? Commented Jul 27, 2010 at 11:15
  • @jAndy & MvanGeest - I put data in quotes in the first code block just to check that I was getting into the callback, and included the screenshot to show that the request is getting the data okay. But when I try to run console.log(data), nothing is outputted to the Firebug console. Commented Jul 27, 2010 at 11:27
  • But even if you call console.log(data) the Response Tab from Firebug should display hey. I can't tell why Firebug does not display the string. You should try to set the dataType to text within your $.get() request. Commented Jul 27, 2010 at 11:40

2 Answers 2

1

The object returned needs to be determined and dealt with appropriately.

From jquery.com "The success callback function is passed the returned data, which will be an XML root element, text string, JavaScript file, or JSON object, depending on the MIME type of the response. It is also passed the text status of the response."

http://api.jquery.com/jQuery.get/

Sign up to request clarification or add additional context in comments.

Comments

0

I would have to say try setting your dataType to text in your $.get request and also double check "../entries/find_most_recent" for any errors (should their be an extension, like: ../entries/find_most_recent.cgi or .html or .php or etc.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.