views:

89

answers:

4

Hello everyone,

I have this code, a simple jQuery GET:

    $.get(url, params, function(){
      function_call()
    })

I wonder why the function_call() is never executed. The server at url is up and running and changing the function to $.ajax() shows no errors (the error option is not executed), but it's not working.

Any clue? params is a simple JS object of two fields, and of course I've used $.get() thousands of times with no problems.

+1  A: 

Based on the information you've given (and the documentation), it should be working. Are you absolutely sure you're actually calling it (the $.get)? Can you create a minimal, self-contained example of the problem? (That does two things: 1. It usually helps you solve the problem yourself, because you figure it out in the process; 2. It gives us more to work with. :-) )

Alternately, anomareh mentioned (in a comment) the Same Origin Policy, which you might be running into.

T.J. Crowder
+1. Let's see the actual code - like the URL.
Matt Ball
A: 

Your syntax looks good. When something like this doesn't work for me, it's because I have a silly mistake at some other point, like a syntax error in the callback function or formulating the URL etc.

We would need to see a little more of your process to help more. Try making you're callback function only do a simple alert. Have an alert right before the $.get() is called, ideally spouting the URL. If you control the server functionality, put a breakpoint there (or whatever you need to do) to make sure the call is getting there. Switch back to $.ajax() and see if you get the error callback function called if you switch the URL to something bogus.

I guess I make so many dumb mistakes with my javascript/jquery, that I'm good with debugging ideas. :)

Patrick Karcher
A: 

out of curiosity, what datatype are you trying to return?

ryan j
A: 

have you tried a semicolon after function_call()?

The only other thing i would try is $.get(url, params, function_call) --- this will work only if your function call has no params -- take note that function_call intentionally does not have () after it.

kmehta