Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:17:04+00:00 2026-06-02T02:17:04+00:00

I am trying to use ajax call to get some values as JSON object

  • 0

I am trying to use ajax call to get some values as JSON object from the server side using JquerMobile framework. This works without any issues in the Desktop Chrome Browser. THis DOES NOT work on the mobile phone browsers. Any help to point out what I am doing wrong here will help. Script below.

$("#showmore").live("click", function(event, param1){
    event.preventDefault();
    getUrl = $(this).attr('href');
    $.post(getUrl, function(data){  
        $('#sname').html(data.name);
    },"json");   
    return false;  
});

If I print the callback data in an alert box I get the current page’s HTML content! In desktop browser I am getting the right values. Thank you for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:17:05+00:00Added an answer on June 2, 2026 at 2:17 am

    I have had this same issue. I have only experienced the issue on an iPad and was not able to find a fix. I was able to find a workaround though.

    Instead of relying on the href attribute, use a data-attribute, like data-href. Set the data-href attribute to the same as the href attribute and reference the data-href attribute in your jQuery code.

    There seems to be a bug where you can’t get the correct href attribute’s value in some versions of Mobile Safari. The reason you are loading the same page with your AJAX request is because the href value returned to you via JS is blank, referring to it’s parent document.

    JS —

    $("#showmore").live("click", function(event, param1){
        var getUrl = $(this).attr('data-href');//no need to create a global variable, so use the `var` keyword here
        $.post(getUrl, function(data){  
            $('#sname').html(data.name);
        },"json");   
        return false;  
    });
    

    HTML —

    <a data-href="foobar.html" href="foobar.html" id="showmore">SHOW MORE!</a>
    

    Note that return false in a jQuery event handler is functionally the same as calling event.preventDefault() and event.stopPropagation() at the same time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am trying to use jQuery to insert data from an ajax call.
I'm trying to get the success data from a jquery Ajax call so I
i am trying to make a ajax call by making use of jquery UI
I am trying to use .ajax() to post a People object to a MVC2
I am trying to use jQuery's ajax functionality to update data from a web
I have a webpage that makes an ajax call to get some data. That
I'm trying to use a Django generated form with a AJAX call for the
I am currently trying to use AJAX in my application via jRails. I am
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I am trying to use periodic refresh(ajax)/polling on my site by XMLHttp(XHR) to check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.