Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing # values with ajax not working

I am trying to get weinre working via Ajax by calling this on dom ready:

$.ajax({
    url: 'http://debug.build.phonegap.com/target/target-script-min.js#hutber',
    dataType: "script",
    crossDomain: true,
    error: function(data){
        c(data.status);
    },
    success: function(data){
        c(data);
    }
});

Now, this is what is being sent:

 http://debug.build.phonegap.com/target/target-script-min.js?_=1381476442102

Which means that, for me to debug i have to use a randomly generated ID. I have tried this also: url: 'http://debug.build.phonegap.com/target/target-script-min.js?_=hutber', Just shooting in the dark.

So, am i write in thinking that the #hutber isn't being correctly sent with the request?

Edit

Just a quick thought, using $.ajax means that I am loading a script dynamically via a http request. As mentioned by Quentin you cannot pass #vars as these are client side. It occured to me however that I could pass the pass if I added the element into the body as if it were there on page load:

var s = document.createElement('script');
s.setAttribute("src","http://debug.build.phonegap.com/target/target-script-min.js#hutber");
document.getElementsByTagName('body')[0].appendChild(s);

Now, things should work out a little better, can't test this theory with a mobile phone however. But fingers crossed.

like image 471
Jamie Hutber Avatar asked Oct 11 '13 07:10

Jamie Hutber


People also ask

Why is it called Passing?

It is based on the 1929 novel of the same name by Nella Larsen, and its title refers to African-Americans who had skin color light enough to be perceived as white, referred to as "passing".

What is the story behind the movie Passing?

The film follows the story of two women who used to be childhood friends, now reunited, and clearly living different lives: while both are light-skinned, Clare (Negga) has been “passing” as a white woman in her relationship with her white husband, John.

What happens at end of Passing?

After Irene suspects that her husband Brian and Clare are having an affair, and after Clare's husband discovers that his wife is Black, a violent confrontation ensues, and the film ends with Clare falling out of a window, her body broken and lifeless on a bed of pure white, Harlem snow.


1 Answers

Yes and No. You are right in thinking that #hutber not being sent with the request, but you are wrong in thinking that this is incorrect.

The fragment identifier portion of a URL is handled purely client side so should never be sent to the server.

If you want to attach data to a URL for the server to process, then use a query string (starting with a ? character and not a # character). If you have both a query string and a fragment identifier then the query string must come first.

jQuery will generate a query string for you if you include a data property to the object you pass to ajax (if you are using GET, as you are here).

data { "_": "hutber" }
like image 123
Quentin Avatar answered Sep 18 '22 11:09

Quentin