?
Solved

How to use Jquery in my jsp

Posted on 2011-05-06
10
Medium Priority
?
268 Views
Last Modified: 2012-05-11


HI how to use jquery in my jsp

 
      $("#x").autocomplete({  
            url:getURL("x"),
            minChars: 1,
            max: 10,
            width: 150,
            scroll: true
            
            
        });
getURL will return some URL and it will go to DB and ftech the result ,
 while i am using this i got object expected java script is error is coming ?

0
Comment
  • 5
  • 4
10 Comments
 
LVL 23

Expert Comment

by:cmalakar
ID: 35706285
Can you post the complete html  ?
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35706570
getURL is called immediately, not when you click on the corresponding textbox
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35719475
>>>getURL is called immediately, not when you click on the corresponding textbox

why it called immediately while page loading with out cilcking the corresponding text box
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 83

Expert Comment

by:leakim971
ID: 35720168
Because as you know "getURL("x")" is the way to call a function.

Try this :


$("#x").autocomplete({  
            url:new Function('getURL("x")'),
            minChars: 1,
            max: 10,
            width: 150,
            scroll: true
            
            
        });

Open in new window

0
 
LVL 83

Expert Comment

by:leakim971
ID: 35720188
or :


$("#x").autocomplete({  
            url:function() {
               getURL("x");
            },
            minChars: 1,
            max: 10,
            width: 150,
            scroll: true
            
            
        });

Open in new window

0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35720427
No Both or not working
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 35720474
check the following :
$("#x").autocomplete({  
            				source: function( request, response ) {

					type = "x";
		
					$.ajax({
						"url": "/x/x.do?action=acfetch&screenName=app&fetch=" + type,
						"data": "term=" + request.term,
						"dataType": "json",
						"success": function(data) {
							response(data.categoryResults)
						}
					});
				},
            minChars: 1,
            max: 10,
            width: 150,
            scroll: true
            
            
        });

Open in new window

0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35720547
actuly the uRl is dynamically blid thats the problem
0
 
LVL 83

Assisted Solution

by:leakim971
leakim971 earned 2000 total points
ID: 35720662
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35746823
I am using the following files is that correct ? when ever i use URL in autocomplete
its give js error !

<script type="text/javascript" src="/xforcesTool/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="/xforcesTool/js/jquery-ui-1.8.12.custom.min.js"></script>
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

807 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