0

This is kinda weird. I've got a workaround for this problem, but I was wondering if anyone knew why it wasn't working. I have a div element on the page called shippingSelect. When I do:

$('#shippingSelect').load('page.asp')

It does not load the corresponding HTML from page.asp into the shippingSelect element. Alternatively, if I do:

$('#shippingSelect').load('page.asp', function(data){
    $('#shippingSelect').html(data);
});

That does work. What's the deal there? Thanks all.

this is exactly what's being loaded...not a whole page:

<a href='#' onclick='getShipping(); return false'>Re-Calculate shipping</a> - <select name='ups_select' id='ups_select' onchange='calculateTotal(this.value);'><option value='13.04|03' selected>UPS Ground ($13.04)</option><option value='56.56|13' >UPS Next Day Air Saver - Gtd. 1 day ($56.56)</option><option value='96.52|14' >UPS Next Day Air. Early A.M. - Gtd. 1 day ($96.52)</option><option value='61.03|01' >UPS Next Day Air. - Gtd. 1 day ($61.03)</option></select>
5
  • Can you paste the exact contents of data? Commented Jun 13, 2012 at 15:01
  • is this single quote exist like this `$ Commented Jun 13, 2012 at 15:04
  • before $ symbol i see ` caracter Commented Jun 13, 2012 at 15:07
  • It don't exists any singe quote on by screen... Commented Jun 13, 2012 at 15:09
  • @MaxAllan: yes cause edited ;) Commented Jun 13, 2012 at 15:12

3 Answers 3

1

The only thing that makes any sense here is that what .load does and what .html functions do are different based on the content passed into them.

You havent included the content so its hard to tell why it breaks, but i bet the page you are loading includes the <html> element and all kinds of other stuff you would never want to load into a div.

You probably dont actually want to load the entire page into our div just a section of it. It would be best to put an id on that section and load just that element like so:

$('#shippingSelect').load('page.asp #container')

see docs

Sign up to request clarification or add additional context in comments.

2 Comments

this is exactly what's being loaded...not a whole page: `<a href='#' onclick='getShipping(); return false'>Re-Calculate shipping</a> - <select name='ups_select' id='ups_select' onchange='calculateTotal(this.value);'><option value='13.04|03' selected>UPS Ground ($13.04)</option><option value='56.56|13' >UPS Next Day Air Saver - Gtd. 1 day ($56.56)</option><option value='96.52|14' >UPS Next Day Air. Early A.M. - Gtd. 1 day ($96.52)</option><option value='61.03|01' >UPS Next Day Air. - Gtd. 1 day ($61.03)</option></select>
from what you stated above, your script should work fine. try to make a small reproducible example on your computer - it will work, then work backwards to see why your code does not.
0

Have you just missed to paste the semicolon or do you miss it in the original? $('#shippingSelect').load('page.asp');

3 Comments

semi colons are optional* in javascript. this is not the cause of this problem.
You sure, cause I had great problems in my jQuery library one time, only because I missed a semi colon...
well, yes they are optional, but omitting them in some cases will lead to unexpected results. You should know what those cases are if you are planning to omit them. This is not one of those cases.
0

Loading whole page into a div element is not adviced, it has lots of extra stuff you don't really need.

Try this for a start:

$('#shippingSelect').load('page.asp body');

To load only the body contents, if no luck add a placeholder around the actual contents, give it id and change 'body' to '#id_here'.

2 Comments

this is exactly what's being loaded...not a whole page: `<a href='#' onclick='getShipping(); return false'>Re-Calculate shipping</a> - <select name='ups_select' id='ups_select' onchange='calculateTotal(this.value);'><option value='13.04|03' selected>UPS Ground ($13.04)</option><option value='56.56|13' >UPS Next Day Air Saver - Gtd. 1 day ($56.56)</option><option value='96.52|14' >UPS Next Day Air. Early A.M. - Gtd. 1 day ($96.52)</option><option value='61.03|01' >UPS Next Day Air. - Gtd. 1 day ($61.03)</option></select>
What you mean? This is the only output of page.asp? No <html> or <head> tags for example?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.