Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does data-ajax="false" really do?

The links on my site don't work and I got an solution of using data-ajax="false" on my anchors without getting a true explanation. Can someone help me?

like image 395
Dan Ovidiu Boncut Avatar asked Nov 13 '12 07:11

Dan Ovidiu Boncut


People also ask

What does data mean in Ajax?

data : The data to send to the server when performing the Ajax request. dataFilter : A function to be used to handle the raw response data of XMLHttpRequest. dataType : The type of data expected back from the server.

How can make Ajax call in jQuery?

The ajax() method in jQuery is used to perform an AJAX request or asynchronous HTTP request. Parameters: The list of possible values are given below: type: It is used to specify the type of request. url: It is used to specify the URL to send the request to.


2 Answers

data-ajax is a feature of jQuery Mobile. JQM by default will try to load pages via ajax for improved user experience and transitions. If you set data-ajax='false' then JQM will do a normal page request instead of using ajax. This can be used on forms as well as links.

From the docs:

This tells the framework to do a full page reload to clear out the Ajax hash in the URL

If you want to disable ajax on all of your links then instead of adding data-ajax to everything, you can do it like this:

$(document).bind("mobileinit", function () {
    $.mobile.ajaxEnabled = false;
});
like image 163
MrCode Avatar answered Nov 06 '22 11:11

MrCode


Nothing at all.

data-* is a generic set of attributes that you can store data in for access by JavaScript.

Unless you have some JavaScript that deals with them, they are meaningless.

jQuery has nothing built in that does anything with them.

like image 45
Quentin Avatar answered Nov 06 '22 13:11

Quentin