Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Jquery and passing load variables onclick

Posted on 2013-01-19
8
Medium Priority
?
250 Views
Last Modified: 2013-01-22
Hi Guys,

Can anyone suggest why this isnt working?

$(".Suggestion").click(function() {
	SuggestedCompany = $(this).text();
	$('#Company').val(SuggestedCompany)
	$('#ExtraDetails').load('/lists/scripts/php/load.extra.php?Company='+SuggestedCompany+'');

});

Open in new window


It adds the value to the input perfectly... but doesnt load the file correctly

Many Thanks for help
0
Comment
Question by:maccaj51
  • 4
  • 4
8 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 38796709
what mean but doesnt load the file correctly
0
 

Author Comment

by:maccaj51
ID: 38796715
It removes content in #ExtraDetails so I assume the load function is working...

However it doesnt load the content of load.extra.php, regardless of passed variable
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38796967
It removes content in #ExtraDetails so I assume the load function is working...
yes that's the goal of using load

However it doesnt load the content of load.extra.php, regardless of passed variable
OK, could you propose a link to see your page?
Try this and let me know what you get in the alert box
$(".Suggestion").click(function() {
	SuggestedCompany = $(this).text();
	$('#Company').val(SuggestedCompany)
var url = '/lists/scripts/php/load.extra.php?Company='+SuggestedCompany+'';
alert( url );
	$('#ExtraDetails').load(url);

});

Open in new window

0
Industry Leaders: 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!

 

Author Comment

by:maccaj51
ID: 38806593
Hi Leakim,

Sorry for delay...

That alerts the correct information...

/lists/scripts/php/load.extra.php?Company=ACAL BFI UK
0
 

Author Comment

by:maccaj51
ID: 38806635
If i change the load url from:

var url = '/lists/scripts/php/load.extra.php?Company='+SuggestedCompany+'';

to a manual entry of:

var url = '/lists/scripts/php/load.extra.php?Company=test';

the load works fine...

Cant understand it
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 38806637
ok replace :
SuggestedCompany = $(this).text();
by :
SuggestedCompany = encodeURIComponent( $(this).text() );
0
 

Author Closing Comment

by:maccaj51
ID: 38806646
You Sir are a Hero!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38806652
the error is due to the space

$("#where_to_put").load("url_to_load   what_to_get_from_page_loaded"); // see the space here
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
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 how to dynamically set the form action using jQuery.
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)

963 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