how to use onclick url change in $.ajax({});
Hello everyone, I am hoping someone can help me.
Here is a little explanation of what it is that i'm trying to do.....
- I am trying to show a price listing for different postcard sizes...
- i need to change the XML url in $.ajax({}); on a click function
- i am using <dl> + css + jquery for my custom dropdown
Here is a sample HTML CODE
<dl id="sample" class="dropdown">
<dt><a href="#"><span> 4 x 6"</span></a></dt>
<dd>
<ul>
<li><a href="#">3.5 x 2"<span class="value">3.5x2</span></a></li>
<li><a href="#">4.5 x 2"<span class="value">4.5x2</span></a></li>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Here is the Javascript
$(document).ready(function () {
$(".dropdown dd ul li a").click(function() {
var sizeurl = getSelectedValue("sample");
function getSelectedValue(id) {
return $("#" + id).find("dt a span.value").html();
}
function xmlParser(xml) { .... }
// parsing works fine.. so i didn't want to clog this post.... so i took it off
$.ajax({
type: "GET",
url: sizeurl + "prices.xml",
// doesn't work, hoping to use "sizeurl" for the prefix (3.5x2prices.xml)
dataType: "xml",
success: xmlParser
});
});
});