Expected identifier or string in javascript

2019-07-28 03:14发布

问题:

function GetHTML(url, para) {
   var data =  $.ajax({
        url: url,
        global: false,
        type: "POST",
        data: para,
        dataType: "html",
        async: false,
    }).responseText;
    return data;
}

well when i run this function it's work good but i got the problem that Visual studio tell me Expected identifier or string

are their anything goes wrong in this code. well tell me what i do to remove this error

回答1:

Remove the comma after async: false,

Try using jslint - it can help pick up things like this.



回答2:

This is probably due to the extra comma after async: false, - that is a syntax error, and wouldn't work on all browsers (If I remember correctly, it doesn't work on IE)