Jquery Uncaught SyntaxError: Unexpected token:

my message is as follows:

$.post('/ajaxvalidate/1', {"nid": nid}, function(data) {

I get an error Uncaught SyntaxError: Unexpected token :in google chrome.

I understand that I need to set the content type or something else from this question: Uncaught SyntaxError: Unexpected token:

I don’t understand how to do this.

http://api.jquery.com/jQuery.post/ has no examples. :( Thanks.

+5
source share
2 answers

The jQuery.post API page provides some examples. They are about 1/3 of the way down the page. The final example on the page shows how to pass this content type to "json" in this method.

jQuery post - jsFiddle :

$(function() {
    $.post("/ajax_json_echo/", {html: "stuff"}, function(data) { alert(data.post_response.html);}, "json");
});

, "json" .

, , . Fiddler Firebug , . , ?

, , .

, .

+8

, $(document).ready(function(){ ); ( })

+2

All Articles