javascript ajax语法错误

I'm really new to javascript and ajax, and I'm having syntax error problems somewhere in below code. I tried to find it myself but after few days I need to ask for some good soul to help me as this is almost impossible to me.

<script type="text/javascript">
new AjaxUpload('#button-option-<?php echo $option['product_option_id']; ?>', {
    action: 'index.php?route=product/product/upload',
    name: 'file',
    autoSubmit: true,
    responseType: 'json',
    onSubmit: function(file, extension) {
        $('#button-option-<?php echo $option['product_option_id']; ?>').after('<img src="catalog/view/theme/moshi/image/loading.gif" class="loading" style="padding-left: 5px;" />');
        $('#button-option-<?php echo $option['product_option_id']; ?>').attr('disabled', true);
    },
    onComplete: function(file, json) {
        $('#button-option-<?php echo $option['product_option_id']; ?>').attr('disabled', false);

    $('.error').remove();

    if (json['success']) {
        alert(json['success']);

        $('input[name=\'option[<?php echo $option['product_option_id']; ?>]\']').attr('value', json['file']);
    }

    if (json['error']) {
        $('#option-<?php echo $option['product_option_id']; 

?>').after('<span class="error">' + json['error'] + '</span>');
        }

        $('.loading').remove(); 
    }
});
</script>

I appreciate any help as I don't know why Dreamweaver shows there is an syntax error

Thanks in advance

Am seeing the syntax error in first line it self,

new AjaxUpload('#button-option-<?php echo $option['product_option_id']; ?>', {

In this you using single inverted comma twice, i think this should be like this,

new AjaxUpload('#button-option-<?php echo $option[' + product_option_id + ']; ?>', {

I just observed in first line, i haven't checked whole code.

why don't you use some advance editor or online editor like http://jsfiddle.net/

Dreamweaver is a pretty poor editor, so it maybe that the errors are not real errors - does this work in a browser?

That aside, the lines like

$('#button-option-<?php echo $option['product_option_id']; ?>')

may be causing it problems due to the nested quotes... it thinks that you've closed a string when you haven't actually.

You could work around this in one of two ways.

You could replace the outer quotes with double quotes

$("#button-option-<?php echo $option['product_option_id']; ?>")

Or, you could pull that PHP out and put it in one place:

<script type="text/javascript">
var productOptionId = <?php echo $option['product_option_id']; ?>;
new AjaxUpload('#button-option-'+productOptionId , {
    action: 'index.php?route=product/product/upload',
    name: 'file',
    autoSubmit: true,
    responseType: 'json',
    onSubmit: function(file, extension) {
        $('#button-option-'+productOptionId).after('<img src="catalog/view/theme/moshi/image/loading.gif" class="loading" style="padding-left: 5px;" />');
        $('#button-option-'+productOptionId).attr('disabled', true);
    },
    onComplete: function(file, json) {
        $('#button-option-'+productOptionId).attr('disabled', false);

    $('.error').remove();

    if (json['success']) {
        alert(json['success']);

        $('input[name=\'option['+productOptionId+'\']').attr('value', json['file']);
    }

    if (json['error']) {
        $('#option-'+productOptionId).after('<span class="error">' + json['error'] + '</span>');
        }

        $('.loading').remove(); 
    }
});
</script>

Finally, it could just be that Dreamweaver doesn't like you mixing JavaScript and PHP.