HTML1506: Unexpected token in IE

category:  Javascript, jQuery, Web development, WordPress

Yesterday, I received a support task from one of my clients. It was urgent because the users could not buy the product online. The issue occurred only in the IE browser(IE11 and IE edge). I checked the error message at the console and I found “HTML1506: Unexpected token“. I saw the same error back in 2015 when I worked with another client in the USA. This error is very common in IE. The cause The sample of JS code that … Read More

How to validate a form with jQuery validation plugin

category:  jQuery, Web development

When you want to do the form validation you can do from the client-side and server-side. I like to do on the client-side so users can get the notification message right away after leaving the input field. The form validation on the client site is very useful when your form contains a lot of fields. On jquery plugin that I often use, it is jquery validation. It is easy to use and I can add my custom method, custom message, … Read More

How to avoid jquery conflicts in WordPress

category:  jQuery, WordPress

WordPress developers know that the jQuery in WordPress runs in noConflict mode. This means when you enqueue the script that is dependent on jQuery in WordPress, you cannot use the common $ alias. To solve this issue, you can place your code using the $ shortcut inside a noConflict wrapper. Here is an example. in PHP file in JS file If you need to load the script in the header after the document is ready, you will use the code … Read More

How to trigger a click on a link using jQuery

category:  jQuery

Today I am working on some small tasks. It should not take long. But I stuck on one issue for a while. Here is what I am trying to do.   I have the page link list that is generated by the pagination_link from WordPress. The code looks like this. $big = 999999999; $url = str_replace($big, ‘%#%’, html_entity_decode(get_pagenum_link($big))); $pagination_dropdown_args = array( ‘base’ => $url, ‘format’ => ‘?paged=%#%’, ‘total’ => $total_pages, ‘current’ => $paged, ‘show_all’ => true, ‘end_size’ => 1, ‘mid_size’ => … Read More

Upload file won’t send to backend with Ajax

category:  jQuery, Web development

Sometimes you create a form by containing the file input field(such as upload image file) and other text input fields. And you want to send all form data to the backend using Ajax. But you find out the only the file input data won’t send to the backend. Why? You may send the form data using serialize(). This is the cause that your backend won’t get the file input data via Ajax. Here is the code snippet using serialize(). $(“body”).on(“beforeSubmit”, … Read More