javascript - How to make a AJAX request to a Desktop version of a site via the Mobile version -


the mobile site i'm working on different desktop version. need make ajax call via mobile site bring in data desktop version. seems ajax call make request on calling version of site.

this code returns mobile site data when called on mobile site:

            $.ajax({                 type: "get",                 url: window.location.href,                 success: function(data) {                     var response = $(data);                     //returns mobile site data                 }             }); 

is there way force request use desktop version?

you're making ajax request the current url:

url: window.location.href 

this highly unconventional. more point, browser doesn't know or care difference between "desktop" , "mobile". makes requests , displays responses. if current url doesn't handle ajax request you'll need make request url does:

url: 'somespecificurl' 

to make easier , consistent through different versions of application, recommend separating ui urls api urls. both versions of ui can make requests same api urls.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -