I would like to know how or if it is possible to use selectors in an ajax request with jQuery
What I would like to achieve, is something like this
$(".classname").load("something.html $(".classname:contains('some text')").parent()");
In other words I would like to pass a complex selector to the requested page other than just a class or an id.
Can anybody help, or is this just impossible? I can't seem to find any other thread where this has been asked!
.load
assumes the text following a space following the URL is a selector. It has to be a textual selector. You have accidentally included the javascript equivalent in the string instead. Try this:
$('.classname').load('something.html .classname:contains("some text"):parent');
You could use .get
instead if the selector is complex.
$.get("something.html", function(data){
$(".classname").html($(".classname:contains('some text')", data).parent().html());
}, "html");
$('.classname').load('something.html *:has(.classname:contains("some text"))')