#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0

    Missing : after property id


    Hallo,

    i'm trying to send a POST request with ajax to reach my REST Server.
    I'm not sure how to do this and which is the best way...

    Actually i hope to reach my target with this code:

    abschicken.js:

    Code:
    function anfrage_abschicken(){
    	var passwordHash = make_base_auth('restbpm');
    	$.ajax({
    		type: "POST",
    		url: "http://localhost:8080/...",
    		contentType: "application/x-www-form-urlencoded",
    		auth-methods: "BASIC",
    		auth-preemptive: true,
    		auth-username: "restuser",
    		auth-password: passwordHash,
    		data: "options=user%3Aadmin",
    		success: function () {
    		      alert('Success');
    	        }
    	}; );
    }
    
    function make_base_auth(password) {
      var hash = Base64.encode(password); //function is too long    
    //to add here, but cant be the problem, i have tested it before
      return hash;
    };
    eingabe.html:

    Code:
    <html>
    	<head>
    		<title>HTTP-Request absenden</title>
    		<script type="text/javascript" src="abschicken.js">		
                    </script>
    	</head>
    	<body>
    		<a href="#"   
                       onclick="anfrage_abschicken()">Abschicken</a>
    		<div id="status">
    			Bitte auf 'Abschicken' drücken.
    		</div>
    	</body>
    </html>
    But something im doing wrong with the syntax. I always get missing : after property id. Tried several versions, like:

    var anfrage_abschicken: function(){...};
    var anfrage_abschicken = function(){...};
    anfrage_abschicken: function(){...};


    But always an error like "missing : ..." or "missing ; ...".
    I dont get it I now there are many results by google, but i cant find my solution...

    Maybe someone can help.
    Thanks!
    Greets,

    sadermader
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    236
    Rep Power
    28
    auth-methods
    You can't have identifiers with dash (minus sign!) inside. Perhaps you can enclose them in quotes however.

    But something im doing wrong with the syntax. I always get missing : after property id. Tried several versions, like:
    You'd better try fixing syntax where it is broken and of course it is bad idea to try fix something by randomly change punctuation without regard of programming language syntax.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0
    hm thank you first.

    You'd better try fixing syntax where it is broken and of course it is bad idea to try fix something by randomly change punctuation without regard of programming language
    I didnt just try everything without thinking about, this is not the first time i develop with Javascript.
    But it dont works, after reading thousand of threads...
    So I have to try something else-_-


    Found the error in ajax-block:

    Code:
    $.ajax({
    			type: "POST",
    			url: "http://localhost:8080/bonita-server-rest/API/runtimeAPI/instantiateProcess/FaultIsolation__Process_PM03--1.0",
    			contentType: "application/x-www-form-urlencoded",
    			// auth-methods: "BASIC",
    			// auth-preemptive: true,
    			// auth-username: "restuser",
    			// auth-password: passwordHash,
    			data: "options=user%3Aadmin",
    			success: function () {
    				alert('Success');
    			}
    		}; //<-wrong semicolon  
     );
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,911
    Rep Power
    1045
    You can't have a semicolon after the object literal (in your Ajax call), because this is not a statement.

    You currently have it like this:

    javascript Code:
    $.ajax({}<img src="http://images.devshed.com/fds/smilies/wink.gif" border="0" alt="" title="Wink" class="inlineimg" />;

    And that's not valid JavaScript syntax.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by Jacques1
    You can't have a semicolon after the object literal (in your Ajax call), because this is not a statement.

    You currently have it like this:

    javascript Code:
    $.ajax({}<img src="http://images.devshed.com/fds/smilies/wink.gif" border="0" alt="" title="Wink" class="inlineimg" />;

    And that's not valid JavaScript syntax.
    yes thank you!

IMN logo majestic logo threadwatch logo seochat tools logo