homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

trying to use $.get()
Paul Williams

 2:27 am on Jan 27, 2012 (gmt 0)

i'm trying to use the $.get() command and something is getting lost in the server.

here is my jquery/axaj call to the server (and server-script)

$.get('putStatus2.php', { dataOut:0 } , processResponse);

and here is the server-script that is supposed to process the data

$data = $_GET['dataOut'];
mysql_select_db($database_connFtH, $connFtH);
$sql = "INSERT INTO cpqc_status (status_index) VALUES ($data)";
mysql_query( $sql ) or die( mysql_error() );
echo $data;

the problem is that when i send dataOut:0 to the server script, then the server doesn't alway stuff the value into the DB. why?

i tried initiating the server-script from a url and setting the value of dataOut to 0 then 1 then 0 then 2 then....0,0,0,1,2,3,4,0,1,0,1....... and everytime, no matter what i send as the value of dataOut, the php script stuffs that value into the DB just fine,

BUT.....when i try to use the Jquery/Ajax call to do it, then it doesn't wont to work "sometimes". its crazy.
usine the Jquery/Ajax call to INSERT the values 0,1,2,3,.. and so on, it works fine, but when i go back to put in 0 it won't do it.

argh ! this is really frustrating.
i'm using IE7, maybe this $.get() doesn't work so good in IE7?

anyone have any ideas?
maybe i'm not setting up the Ajax command properly?

also, when i try to convert both sides (client-script/server-script) to $.post() and $_POST(), oh boy that wont work at all.
i have no idea what's wrong. according to all my references the syntax is correct. (maybe my references are wrong, but i don't think so)

would appreciate your input very much.
Paul Williams



 2:45 am on Jan 27, 2012 (gmt 0)

Safer to use string value for dataOut.

$.get('putStatus2.php', { dataOut:'0' } , processResponse);



 3:02 am on Jan 27, 2012 (gmt 0)

Possibly a browser caching issue. You might try including some dynamic value, like a date/time stamp.

Paul Williams

 5:49 am on Jan 27, 2012 (gmt 0)

thanks for the response. i have tried string values but it didn't help.

my only clue is that when initiating the server/php from a url and passing along a variable with value such as http//localhost/test/putStatus2.php?dataOut=0 works perfectly,

while not doing so and only calling from $.get() works sometimes...........uh i kinda suspect something is not right either in the calling syntax or maybe IE7 doesn't support $.get() or $.post() so well (?).

also still very strange that linking up $.get() and $.post() on both sides of the fence (client / server) works and doesn't work.

example: $.post(url, callback) that passes no data, linked with $_POST that receives no data works fine,
however.....if you pass data between those two, it doesn't work at all!
now that is weird, almost makes me think its a browser issue, not a code issue. the syntax for these stmts are just too easy.

not sure what you mean by adding date/time stamp?

i'd also like to ask, has anyone had trouble using $.get() and $.post() in IE7?

thank you both,


 2:09 pm on Jan 27, 2012 (gmt 0)

jQuery's get [api.jquery.com] method is shorthand for:

url: url,
data: data,
success: success,
dataType: dataType

If you look at jQuery's ajax [api.jquery.com] method, you'll see that it has a setting for cache which defaults to true. This means that IE will cache the result of the get request. You can't set the cache setting in the "get" method itself, but you can call the ajaxSetup [api.jquery.com] method to do this before calling get:

$.ajaxSetup({cache: false})

Paul Williams

 5:04 am on Jan 29, 2012 (gmt 0)


got it resolved.
it was nothing more than IE7 not wanting to cooperate with Javascript/Jquery/Ajax.
seems to be a common problem.

downloaded FIREFOX v.9 for Windows, and it ran perfect time and time and time again.

thanks for all your help.
Paul Williams


 8:24 pm on Jan 29, 2012 (gmt 0)

I would still suggest you turn off caching as described above.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved