tags:

views:

33

answers:

2

hey i use jquery to insert a form into a div, the form is in a php file. function show(id){ var content = $("#layer1_content");

  $("#layer1").show();

   var targetUrl = "mouse.php?cat="+id;

 content.load(targetUrl);

}

so everything works, but when i submit it goes too that php page, if i call the same form within the same php then it works fine. the response is handled by:

$('#layer1_form').ajaxForm({ target: '#content', success: function() { $("#layer1").hide(); } });

A: 

Your question is not super clear but my hunch is that in the case when it does not work, you are actually submitting the form. This would cause the page reload.

Try grabbing the form and attaching a submit handler that cancels the submit:

$('form').submit(function(){ return false; });
Marcus Westin
A: 

hey, thanks for reply, i just fixed it but in a very cheap manner.

Il try explain again, my jquery gets the contents from a php file like so:

stuff....here..

this calls a div that pops up:

function show(id) { var content = $("#layer1_content");

            $("#layer1").show();

var targetUrl = "mouse.php?cat="+id;
content.load(targetUrl);}

and this is supposed to submit and send back the results from the php "savesettings"

$('#layer1_form').ajaxForm({

target: '#content', success: function() { $("#layer1").hide(); } });

above : #content is were the output will show.

layer1 is the div that holds the form.

if #layer1 div is were my javascript is then, everything works, and the #content div receives the info. But i cant put it the form in the same file cause it will contain alot of settings that will fill the page horribly.

so what i did was (and this is cheap of note i am sure)

this, i took all the stuff inside the form, and called it externally, so that did the trick but it feels cheap :

Iput i new div hre

you think my solution is pathetic?