jQuery Ajax POST example with PHP

Basic usage of .ajax would look something like this: HTML: <form id=”foo”> <label for=”bar”>A bar</label> <input id=”bar” name=”bar” type=”text” value=”” /> <input type=”submit” value=”Send” /> </form> jQuery: // Variable to hold request var request; // Bind to the submit event of our form $(“#foo”).submit(function(event){ // Prevent default posting of form – put here to work … Read more

SecurityError: Blocked a frame with origin from accessing a cross-origin frame

Same-origin policy You can’t access an <iframe> with different origin using JavaScript, it would be a huge security flaw if you could do it. For the same-origin policy browsers block scripts trying to access a frame with a different origin. Origin is considered different if at least one of the following parts of the address … Read more

Check if a user has scrolled to the bottom (not just the window, but any element) [duplicate]

Use the .scroll() event on window, like this: $(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) { alert(“bottom!”); } }); You can test it here, this takes the top scroll of the window, so how much it’s scrolled down, adds the height of the visible window and checks if that equals the height of the overall … Read more

How to get URL parameter using jQuery or plain JavaScript?

Best solution here. var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split(‘&’), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split(‘=’); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } return false; }; And this is how you can use … Read more

Remove ALL white spaces from text

You have to tell replace() to repeat the regex: .replace(/ /g,”) The g character makes it a “global” match, meaning it repeats the search through the entire string. Read about this, and other RegEx modifiers available in JavaScript here. If you want to match all whitespace, and not just the literal space character, use \s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)