Solved

Jquery and passing load variables onclick

Posted on 2013-01-19
8
234 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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)

726 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