• Home
  • About
  • Job Profile
  • Portfolio
  • Training
Blue Orange Green Pink Purple

Posts Tagged ‘Uncaught SyntaxError’

You can use the search form below to go through the content and find a specific post or page:

Jul 08

Javascript function parameter issue : Uncaught SyntaxError: Unexpected token = in Google Chrome

In Javascript, we often use functions for common tasks. Recently I have fallen in a problem where i have written a function to get ajax call which is common for some actions. That function has a parameter to get the URL which needed for ajax call. It was ok in Firefox, but in chrome, all other JS work stopped, due to the parameter error, that is ‘parameter default value’. Solution is, you can’t assign a default value to the function parameter. More explanation here: Function default parameter.

So we need to use below way for browser compatibility:

function get_ajax_fields(parameter){
        flds_request = jQuery.ajax({
            url: baseURL+"dataimport/"+parameter,
            dataType: "json"
        });
        return flds_request;
}

We can't use like this: parameter=''

Hope the issue can save your time! Enjoy!!

Saif The Green

  • View Saif's profile on LinkedIn
  • Recent Posts
    • RESTful API – The HTTPish …
    • SUSE – another user-friendly desktop Linux distributions
    • SEO meta techniques for a wordpress blog
    • Set favicon in cross browser and more…
    • WordPress custom URL rewrites and tips
  • Archives
    • October 2016
    • August 2016
    • August 2014
    • July 2014
    • April 2014
    • June 2013
    • April 2013
    • March 2013
  • Categories
    • CodeIgniter
    • Javascript
    • Linux
    • MySQL
    • opencart
    • php
    • SEO
    • Software Development
    • Web Development
    • Web Services
    • Wordpress
  • Meta
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Archives
    • October 2016
    • August 2016
    • August 2014
    • July 2014
    • April 2014
    • June 2013
    • April 2013
    • March 2013
  • Search







Saif The Green is proudly powered by WordPress
Entries (RSS) and Comments (RSS).