jQuery Mobile: Sending data from one page to the another

jQuery Mobile provides several methods to pass data between pages. The most common approaches include URL parameters, localStorage, and sessionStorage.

Method 1: Using URL Parameters

Pass data through the URL query string when navigating between pages.

HTML Link with Parameters

<a href="new.html?structure=123&type=mobile">Go to New Page</a>

JavaScript to Extract Parameters



    
    





Method 2: Using localStorage

Store data in localStorage before navigation and retrieve it on the destination page.



    





Method 3: Using jQuery Mobile Data Attributes

Pass data using jQuery Mobile's built-in data handling.



    
    





Comparison of Methods

Method Data Persistence URL Visible Best For
URL Parameters Page reload safe Yes Simple data, bookmarkable links
localStorage Browser session No Complex objects, sensitive data
Data Attributes Single navigation No Temporary data transfer

Complete Working Example



    





Structure ID: 123
Type: mobile
Processing structure with ID: 123

Conclusion

Use URL parameters for simple, bookmarkable data. Choose localStorage for complex objects or when data needs to persist across page reloads. jQuery Mobile's data attributes work well for temporary data transfer between pages.

Updated on: 2026-03-15T23:18:59+05:30

242 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements