PHP/JQuery/AJAX, few teething problems...
Posted
by thebluefox
on Stack Overflow
See other posts from Stack Overflow
or by thebluefox
Published on 2010-05-24T11:40:47Z
Indexed on
2010/05/24
11:51 UTC
Read the original article
Hit count: 485
Morning/Afternoon guys.
Writing some JQuery AJAX shizz and getting a bit stuck. I've got the actual proccess of calling the php file done perfectly, its just trying to get the html on the page to change in a way I want it to. I want to get rid of the a with the id of the one used in the ajax call etc, and replace it with the html passed from the PHP file. Code is as follows...
$(".save_places").click(function() {
$.ajax({
url: "{/literal}{$sRootPath}{literal}system/ajax/fan_bus.php",
type: "POST",
data: ({id : this.getAttribute('id')}),
dataType: "html",
success: function(msg){
$(this).before(msg);
$(this).empty();
alert(msg);
}
});
return false;
});
And the HTML is pretty simple;
<p class="links">
<a href="#" class="save_places" id="bus_{$businesses.results[bus].id}_{$sMemberDetails.id}"><img src="{$sThemePath}images/save_places.png" alt="Save to My Places" /></a>
<a href="#"><img src="{$sThemePath}images/send_friend.png" alt="Send to a Friend" /></a>
</p>
All the stuff in the success function is experimental mashing of code, any help please?
Thanks as always.
© Stack Overflow or respective owner