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

The mobile site I'm working on is completely different than its desktop version. I need to make an AJAX call via the mobile site that will bring in data from the desktop version. It seems that the AJAX call will make the GET request only on the calling version of the site.

This code only returns the mobile site data when called on the mobile site:

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

Is there any way to force the GET request to use the desktop version?

-------------Problems Reply------------

You're making an AJAX request to the current URL:

url: window.location.href

This is highly unconventional. But more to the point, the browser doesn't know or care what the difference is between "desktop" and "mobile". It just makes requests and displays the responses. If the current URL doesn't handle the AJAX request then you'll need to make the request to a URL that does:

url: 'someSpecificUrl'

To make this easier and consistent through the different versions of your application, I recommend separating your UI URLs from your API URLs. Both versions of the UI can then make requests to the same API URLs.

Category:javascript Views:40 Time:2019-03-17

Related post

  • how to make an ajax request after sending data by post? 2010-06-30

    i meet a problem, when try to make an ajax request after sending data by post. let's assume i have a index.php file. In the form i send data by post to the same file, and after posting i want to make ajax request, but it don't doesn't happen, because

  • jQuery: How to make an AJAX request and continue without waiting for request to complete? 2010-09-23

    I want to make an AJAX request "in the background" of my JavasSript function, but my script waits for the AJAX request to complete before it continues to execute my code. $('div').hide(); $.get('/controller/action', { id: 'abc123' }, function(data){

  • How to make simultaneous ajax request to get JSON content from different URL's 2011-05-25

    I need to make 10 simultaneous ajax request to get JSON content from different URL's. Each request response is not dependent on each others. In this case how do I manage those requests?? I try using AjaxManager plugin but I can't configure it right t

  • How To Make An AJAX Request In a JS Popup? 2010-10-18

    I have a problem With a "Special" AJAX Request. I have a Form with several combos ("Select" tag). I'm loading the items for each combo from a MySQL DB, with a Special class designed for me. Each Combo has a "+" Button (For Open a Pop-Up and Add a new

  • How to make Multiple ajax requests in a loop return values sequentially? 2012-04-11

    I have to make a series of Ajax requests on a loop. Around 100 of them. And each request returns a JSONP variable. I extract data from the JSON and keep appending the value into a div. The problem is that I want the div to be appended with data in th

  • How to make an AJAX-request look like a regular, normal request 2011-06-21

    What parameters on a $.ajax must I set to try and mask the AJAX-request as a normal request? I guess it has to do with the right headers. I think a big part of the problem is that when working on a local .html-file, jQuery sets the header-value for O

  • How to make an ajax request to an API using CORS and backbonejs 2012-04-05

    I'm working on a backbone.js project and I'm calling my github repo. I have the my Collections and Models bootloaded so they exist once my page is built, but when I call model.fetch() I get this message: (replace :username with a username) XMLHttpReq

  • How to make jQuery AJAX request with a HTTP Handler in Sharepoint 2010? 2011-08-03

    I'm developing a SP 2010 Visual Web Part that needs to load some data via AJAX. I found this very helpful article but I'm having some doubts about it. I have the Visual Web Part project, inside I have the Visual Web Part and some other files. The art

  • How to check an Ajax request in cakephp? 2010-01-22

    How to check an Ajax request in cakephp? --------------Solutions------------- Depends on the version of cake. 1.3.x: $this->RequestHandler->isAjax(); 2.x $this->request->is('ajax'); You need to enable the RequestHandler component var $com

  • If Internet goes down while we make a Ajax Request then how to give feedback to the user that the internet is down? 2010-11-08

    If Internet goes down while we make a Ajax Request then how to give feedback to the user that the internet is down ? --------------Solutions------------- You can define a timeout on AJAX request, if timeout is reached you can then choose best way to

  • How do I make an AJAX request to an ASP.NET webform using $.getJSON? 2012-02-01

    Using an example from a book that I have, I was able to successfully make an AJAX request to an ASP.NET webform using jQuery's $.ajax. However, I have not been successful in using $.getJSON, $.get, or $.post. Is it possible to use $.getJSON (or the o

  • How to make all AJAX calls sequential? 2009-07-20

    I use jQuery. And I don't want concurrent AJAX calls on my application, each call must wait the previous before starting. How to implement it? There is any helper? UPDATE If there is any synchronous version of the XMLHttpRequest or jQuery.post I woul

  • How to make an Ajax loader follow mouse? 2009-09-05

    I want to have something on my site that follows the mouse around, sort of like how Windows 7 does it. Like in Windows 7 when something is loading up a little circle comes and follows the mouse. I am using the jQuery library so I know I can use Ajax

  • How do you handle ajax requests when user is not authenticated? 2010-04-05

    How do you handle ajax requests when user is not authenticated? Someone enters the page, leaves room for an hour, returns, adds comment on the page that goes throuh ajax using jQuery ($.post). Since he is not authenticated, method return RedirectToRo

  • How to Make a Ajax Call from inside an Div That Has Been Called By Ajax? 2011-01-26

    I Have a PHP page that is like this: Here is the Schematics: In DIV 1 And DIV 2 i made Ajax calls for Content. The Ajax Calls Are made from the main Page. If i want to make a call From DIV 1 to change DIV 2 it doesnt Work =/ I Tried: document.getElem

  • How to make an ajax with JQuery with cross site scripting? 2011-06-08

    i'm with a problem that i have to get the json from here: http://templodasdeusas.com.br/game/srv/game.php?srv=home there is an option too to add callback function name like: http://templodasdeusas.com.br/game/srv/game.php?srv=home&callback=myFunc

  • Make an ajax request with elements attributes with jquery 2011-11-18

    I want to make an ajax request where I want to give all my elements attributes. For exemple i select all my elements : var elements = $('.droppable') and then i make my ajax : $.ajax({ url: "test.html", data: {myelements : elements}, success: functio

  • How to make an AJAX call without jQuery? 2011-12-19

    How to make an AJAX call using JavaScript, without using jQuery? --------------Solutions------------- With "vanilla" JavaScript: <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+,

  • How to cancel an ajax request in Django when new page is requested 2012-01-25

    In my web page (built on the Django platform), I have some jQuery that requests server data via an ajax request. How do I prevent the error function from executing when I click away from the page before the ajax request has responded. Here is my jQue

  • How to make SOAP WSDL request in Objective-C? 2010-02-11

    I have a WSDL script which has the following format <definitions name="ProcessData" targetNamespace="urn:ProcessData"> <message name="CreateAccount"> <part name="firstName" type="xsd:string"/> <part name="lastName" type="xsd:stri

  • Can we make an ajax request to a usercontrol (.ascx)? 2010-07-28

    I have a page that contains a user control. Can i make an ajax request directly to the control? I know I can make an ajax request to .aspx or .ashx; however, is it possible to go direct to the .ascx? --------------Solutions------------- In an ASP.NET

  • how to stop jquery ajax request sent via $.get? 2010-11-12

    i am making a ajax request using $.get as soon as the user types a character in the input box i want to abort the previous ajax calls and then make the new one, is there a way? edit solved! i just found out that $.get is a shorthand way to $.ajax and

  • Rails 3: How to make an Ajax call? 2011-03-12

    I would like to have a link (is there a better option?) on my page which will make an Ajax request when clicked. (I would like to update a field in my database when the link is clicked.) What is the simplest way to achieve this ? Could you refer me t

  • How to use normal ajax request on any jsp/servlet to get response 2011-07-24

    I want to create login form in CQ5 using normal JSP & AJAX request with database. Can any one tell me the steps how to use normal JSP and AJAX in CQ5? --------------Solutions------------- At the server-side, an AJAX handler can be implemented the

  • How to make display "AJAX Loading.gif" at image gallery section? (jQuery) 2011-10-11

    I need a little help, i'm trying how to make display "AJAX loading.gif" is an animated gif at image content. When you click a thumbnail, the image takes loading but it doesn't show animated gif, i'm wondering how... http://bksn.mx/opequimar/renta_des

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.180 (s). 11 q(s)