/    Sign up×
Community /Pin to ProfileBookmark

AJAX – Post client side screen width to server side php file

I have done this and its works fine but its not really efficient picking up the screen width when the orientation of the device has changed (IT DOES) but is a bit slow but works perfect

[code]
$(document).ready(function() {
var width;
width = $(window).width();
var screenWidth = width;
$.ajax({
method: “POST”,
url: “menu.php”,
data: {
screenWidth : width
},
success: function (res) {
$(‘body’).html(res);
}
});
});
[/code]

I’m aware of orientationchange function but not quite sure how to piece it together with say for example device that don’t have an orientation change such as desktop/ laptop devices

Does anyone have a better/ more efficient way of doing this (posting the client’s screen width to a server side PHP script) including for orientation change.

to post a comment

0Be the first to comment 😎

×

Success!

Help @nsath spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.11,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...