1

I'm using this code as the starting point to an overhaul of our JavaScript framework:

$("#get").click(function(){
    $("#result").html(ajax_load);
    $.get(
        "http://www.google.com",
        {},
        function(responseText){
            $("#result").html(responseText);
        },
        "html"
    );
});

But when the request is made it includes a variable within the URL that I am unfarmiliar with, here is what Firebug says it's requesting:

http://www.google.com/?_=1268993359215

How do I get rid of this, when we target our internal scripts it's firing a 404 error :-(

Cheers!

3 Answers 3

2

That parameter is used to force browser not to use cache.

You can not make $.get work without it explicitly, but you can use $.ajax instead:

$("#get").click(function(){
    $("#result").html(ajax_load);
    $.ajax({
        url: "http://www.google.com",
        data: {},
        success: function(responseText) {
            $("#result").html(responseText);
        },
        cache: true,
        dataType: "html"
    });
});

Note the extra parameter cache: true. More on $.ajax here: http://api.jquery.com/jQuery.ajax/

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

1 Comment

Ah I see, that makes sense. Google was just an example, we can probably convert our internal scripts to prevent 404s :-), many thanks for your answer!
1

Try this, before any $.get put this code

$.ajaxSetup({cache:true});

Comments

1

Forcing the browser not to cache the target page is a good thing. Can you change your internal scripts to not 404 when extra GET variables are present? (It is a pretty strange way for them to behave)

1 Comment

Yes I can, this question was more about understanding the problem so I can make the correct decisions. Thanks :)

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.