jquery .post with $(“html”).html(data), body css not working

i’m using the following code to submit a form:function submitfilter() alert(“in here”); var o = $(“#opentimes”).val(); var p = $(“#price”).val(); var d = $(“#distance”).val(); var t = $(“#type”).val(); $.post(“eateries.php”, opentimes: o, price: p, distance: d, type: t , function(data) …

via Css Website development » Search Results » ajax:

jquery .post with $(“html”).html(data), body css not working

i’m using the following code to submit a form:
function submitfilter()
alert(“in here”);
var o = $(“#opentimes”).val();
var p = $(“#price”).val();
var d = $(“#distance”).val();
var t = $(“#type”).val();
$.post(“eateries.php”, opentimes: o, price: p, distance: d, type: t , function(data) $(“html”).html(data); );
return false;
}i’m running this from eateries.php, so as you can see i want to reload the same page (like a regular form submit does). everything is working fine except that some of my CSS isn’t working. specifically:
bodyfont-family:Arial, Helvetica, sans-serif; font-size:14px; margin:0px;color:red;the rest of the CSS seems to be working fine. what’s going on here??
edit: another thing i should probably mention is the CSS does work for a second.. while that alert(“in here”) is up (the text is Arial and red). however, after i hit “Ok”, the font goes back to black serif.
thanks.
edit: here’s the head section as requested.




………………………………..

You are replacing the innerHTML of the tag in the callback to the $.post! If you use firebug, you might notice that the body is disappearing all together.
A quick fix would be to target $(“body”) instead of $(“html”) in that $.post callback. Otherwise, make another element to populate with the return of that callback.
………………………………..

Assuming that line of CSS is in style.css in the same directory as this html file, there is no reason to believe that the CSS “isn’t working” as your syntax is perfectly correct. Maybe make sure that you have a proper doctype directly above the tag.
Also, as Nick mentioned in a comment to your question, why are you using AJAX if you desire to reload the page anyway? (just noticed your reply concerning the proxy, however I’d start by looking into this)
UPDATE: You never even mention what gives you the impression that the “CSS isn’t working.”

NOTE: I’ll update this as you give more information.

For more info: jquery .post with $(“html”).html(data), body css not working

Css Website development » Search Results » ajax

jquery .post with $(“html”).html(data), body css not working

Share this post:

Related Posts

Leave a Comment