Solved

Jquery and passing load variables onclick

Posted on 2013-01-19
8
235 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
[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
  • 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 500 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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 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…

728 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