syntax error: unexpected token <

后端 未结 15 2030
一整个雨季
一整个雨季 2020-11-29 02:20

I\'ve tried many things and there\'s no way, always appears this error I tried to use only one option to see if passed, changed the call of jquery, but not.

I looked

相关标签:
15条回答
  • 2020-11-29 03:07

    When posting via ajax, it's always a good idea to first submit normally to ensure the file that's called is always returning valid data (json) and no errors with html tags or other

    <form action="path/to/file.php" id="ajaxformx">
    

    By adding x to id value, jquery will not process it.

    Once you are sure everything is fine then remove the x from id="ajaxform" and the empty the action attribute value

    This is how I sorted the same error for myself just a few minutes ago :)

    0 讨论(0)
  • 2020-11-29 03:09

    I had a similar problem, and my issue was that I was sending javascript to display console messages.

    Even when I looked at the file in my browser (not through the application) it showed exactly as I expected it to (eg the extra tags weren't showing), but there were showing in the html/text output and were trying to be parsed.

    Hope this helps someone!

    0 讨论(0)
  • 2020-11-29 03:09

    i checked all Included JS Paths

    Example Change this

    <script src="js/bootstrap.min.js" type="text/javascript"></script>
    

    TO

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script>
    
    0 讨论(0)
  • 2020-11-29 03:09

    This happened to me with a page loaded in via an iframe. The iframe src page had a 404 script reference. Obviously I couldn't find the script reference in the parent page, so it took me a while to find the culprit.

    0 讨论(0)
  • 2020-11-29 03:19

    This error can also arise from a JSON AJAX call to a PHP script that has an error in its code. Servers are often set up to return PHP error information formatted with html markup. This response is interpreted as invalid JSON, resulting in the "unexpected token <" AJAX error.

    To view the PHP error using Chrome, go to the Network panel in the web inspector, click the PHP file listed on the left side, and click on the Response tab.

    0 讨论(0)
  • 2020-11-29 03:21

    Just ignore parameter passing as a false in java script functions

    Ex:

    function getCities(stateId,locationId=false){    
    
        // Avoid writting locationId= false kind of statements
       /*your code comes here*/
    
     }
    

    Avoid writting locationId= false kind of statements, As this will give the error in chrome and IE

    0 讨论(0)
提交回复
热议问题