i want to Post a form value with Jquery $.POST() and load a specific selector i don't know how to do it may be with json or something like that
$.post('topic.php', {
id: id
}, function(data) {
$("#message")
.html($(data).('attr', 'title'))
.hide()
.slideDown(500); //Fade in the data given by the topic.php file
});
return false;
});
i just want to load the title and description not the whole page
i want to retrieve this title and description in a lightbox how can i do it?
First, jQuery (and even many browsers internally) sends a HTTP_X_REQUESTED_WITH header. You could catch it in topic.php and returns json instead of html. Check this link for an how-to: http://www.electrictoolbox.com/how-to-tell-ajax-request-php/
If you really want to extract content from returned html, it's fairly simple: create a blank DOM object with jQuery, give it the HTML data, then retrieve whatever element you want with the find function:
$.post('topic.php', {
id: id
}, function(data) {
$("#message")
.html($('<div></div>').html(data).find('a').('attr', 'title'))
.hide()
.slideDown(500); //Fade in the data given by the topic.php file
});
return false;
});
Replace the 'a' tag in find function by any selector you need. A working example here: http://jsfiddle.net/GeX7d/
EDIT: for the lightbox part, there are plenty of tutorials on the web that describe the process, this one will fit your needs: http://www.cssjockey.com/web-design-tutorials/an-easy-way-to-create-light-box-with-jquery-css