Ajax response doesn't work in Mobile Safari after adding custom http headers
===

i'm using a UIWebView in order to realize a iPhone web-app, i need to add a custom headers in NSURLRequest, i do this in this way:

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    {
        if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) 
          {
            if ([[request allHTTPHeaderFields] objectForKey:@"customHeader_1"] == NULL ){
    			NSMutableURLRequest *mutableReq = [request mutableCopy];
    			[mutableReq addValue:@"1" forHTTPHeaderField:@"customHeader_1"];
        		[mutableReq addValue:@"2" forHTTPHeaderField:@"customHeader_2"];
    		
    		    [self.webView loadRequest:mutableReq];
    		  }
           } 
    	return YES;
    }

when i load the "index" page it works, but when i try to go in a different page with ajax POST (the same happens with GET)

    $.ajax({
                    url: url,
                    type: 'POST',
                    dataType: 'text',
                    success: callbackSucDetail2,
                    error: function (xhr, ajaxOptions, thrownError) {
                        window.alert("status :" + xhr.status + " error: " + thrownError + " option: " + ajaxOptions);
                    }
                });

it doesn't work. Without custom headers all pages work.
I found a solution by adding a query string in the url,

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    {
        if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) 
          {
            if ([[request allHTTPHeaderFields] objectForKey:@"customHeader_1"] == NULL ){
    			NSMutableURLRequest *mutableReq = [request mutableCopy];
    			[mutableReq addValue:@"1" forHTTPHeaderField:@"customHeader_1"];
        		[mutableReq addValue:@"2" forHTTPHeaderField:@"customHeader_2"];
    			
    			NSString *stri = [[request URL] absoluteString];
                [murl setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", stri, @"?test=test"]];;
    
    		    [self.webView loadRequest:mutableReq];
    		  }
           } 
    	return YES;
    }

but this isn't a "clean" solution. Someone may explain me this strange behavior?