Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jquery and passing load variables onclick

Posted on 2013-01-19
8
Medium Priority
?
239 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
Independent Software Vendors: 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

715 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