Solved

syntax error on line 53

Posted on 2012-04-11
5
442 Views
Last Modified: 2012-06-21
syntax error on line 53.

I'm following a simple ajax>php>mysql example posted here http://openenergymonitor.org/emon/node/107

I've come across syntax error on line 53 and I don't know how to fix this?

<!---------------------------------------------------------------------------------------------
Example client script for JQUERY:AJAX -> PHP:MYSQL example
by Trystan Lea : openenergymonitor.org : GNU GPL

I recommend going to http://jquery.com/ for the great documentation there about all of this
---------------------------------------------------------------------------------------------->
<html>
  <head>
    <script language="javascript" type="text/javascript" src="jquery.js"></script>
  </head>
  <body>

  <!---------------------------------------------------------------------------------------------
  1) Create some html content that can be accessed by jquery
  ---------------------------------------------------------------------------------------------->
  <h2> Module No2 </h2>
  <h3>Output: </h3>
  <div id="output">this element will be accessed by jquery and this text will be replaced</div>

  <script id="source" language="javascript" type="text/javascript">

  $(function () 
  {

    //-------------------------------------------------------------------------------------------
    // 2) Send a http request with AJAX http://api.jquery.com/jQuery.ajax/
    //-------------------------------------------------------------------------------------------
    $.ajax({                                      
      url: 'api.php',                  //the script to call to get data          
      data: "",                        //you can insert url argumnets here to pass to api.php for example "id=5&parent=6"
      dataType: 'json',                //data format      
      success: function(rows)          //on recieve of reply // change from data to rows
      {
		for (var i in rows)
         {
          var row = rows[i];          

          var id = row[0];				//get id //var id = row[0];	
          var vname = row[1];			//get name // var vname = row[1];
  
	
        //--------------------------------------------------------------------------------------
        // 3) Update html content
        //--------------------------------------------------------------------------------------
       			// $('#output').html("<b>id: </b>"+id+"<b> name: </b>"+vname);     //Set output element html
        //recommend reading up on jquery selectors they are awesome http://api.jquery.com/category/selectors/
      $('#output').append("<b>id: </b>"+id+"<b> name: </b>"+vname)
                  .append("<hr />");
    } 
  } 
});

  </script>
   
  </body>
</html>  

Open in new window

0
Comment
Question by:Redscrapbook
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:macarrillo1
ID: 37835988
There is a problem with your '(' and '{'
line 28 has ({
line 33 {
line 35 {
line 47 missing )
line 49 }
line 50 }

you are missing a total of  one }  and two ).
0
 
LVL 9

Expert Comment

by:macarrillo1
ID: 37835997
It looks like you are missing the closing }); from the $.ajax

Sorry my mistake on line 47.  It is good as it is.
0
 

Author Comment

by:Redscrapbook
ID: 37835999
ok can you replace  a missing part? I can't see anything please?
Show it in codes of a missing part.
0
 
LVL 9

Accepted Solution

by:
macarrillo1 earned 500 total points
ID: 37836017
Change line 52 to:

});

You need to close the function from lines 22 and 23 and close the $.ajax from line 28.
Both these statements need to be closed with });.  You only have one on line 51. Thus you need to add another on line 52.
0
 

Author Closing Comment

by:Redscrapbook
ID: 37836025
That is a fastest response...in ten minutes.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question