Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
Uncaught SyntaxError: expected expression, got ','

Im getting this error and I don't understand why. The js seems to be right to me. Clearly Im missing something. Any help would be appreciated.

JS:

            var doPostBack = function(UserId, TokenKey, opcao)
            {
                $.ajax({
                type: ""POST"",
                url: ""https://localhost:44382/Home/do_PostBack"", 
                data: {UserId: UserId, TokenKey: TokenKey, opcao: opcao}, 
                contentType: ""application/json; charset=utf-8"",
                success: function() {
                    
                    },
                failure: function() {
                        
                    },
                error: function() {
                        
                    }
                });
            }

HTML:

<a href="javascript:do_PostBack({TokenId}, {TokenKey}, {11})">
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Mismatch function name and parameter

<a href="javascript:do_PostBack(TokenId, TokenKey, 11)">Api Call</a>

JSON.stringify data before sending. You can also use property shorthand.

var do_PostBack = function(UserId, TokenKey, opcao)
{
    console.log(UserId, TokenKey, opcao);
    $.ajax({
        type: "POST",
        url: "https://localhost:44382/Home/do_PostBack", 
        data: JSON.stringify({ UserId, TokenKey, opcao }), 
        contentType: "application/json; charset=utf-8",
        success: function() {

        },
        failure: function() {

        },
        error: function() {

        }
    });
}
about 4 years ago · Juan Pablo Isaza Report

0

There are double quotation marks in the type, url and contentType fields. This would make it invalid.

Below is the fixed function. I also changed 'var'to 'let'. But make sure this would not brake anything in your application.

let doPostBack = function(UserId, TokenKey, opcao) {
  $.ajax({
    type: "POST",
    url: "https://localhost:44382/Home/do_PostBack",
    data: {
      UserId: UserId,
      TokenKey: TokenKey,
      opcao: opcao
    },
    contentType: "application/json; charset=utf-8",
    success: function() {

    },
    failure: function() {

    },
    error: function() {

    }
  });
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!