0

Hey everyone I am trying to .submit some values with ajax response and i want to stay on current page with no refresh or $_POST.

At the 3rd image you will se my jquery script. I tried to alert('1'); etc in it. Even in the first line of function it does not alert. Strangely, It does the $_POST of the form. but not my ajax submit. as it doesnt do any process, "return false;" doesnt work too.

At the 2nd image, you see my form tag, its ID is correct its action is set to a javascript which is not necessary to run. I tried it with no "method" with no "action" with "javascript:;"

At the 1st image you will see where should my ajax response get placed. I'm searching for answer for hours. Thanks in advance for any help or comments.

Where it should return answer my form action and method jquery part of the code

4 Answers 4

2

Remove the current return false; because it only runs if the condition in the if statement is true.At the end of the submit block, add return false;

Example:

$('#livehesap').submit(function(){

// ...
// ...
// ...
  return false;
});
Sign up to request clarification or add additional context in comments.

1 Comment

tried. But still does post. Then tried to add 2nd return false; without removing 1st. Still did post. Anyway in anycasy, #sonfiyat div still did not change.
1

@Mustafa, you should look at the jQuery Form Plugin, it makes "ajaxifying" forms very easy - http://jquery.malsup.com/form/

1 Comment

didnt work on my or at least i couldnt run it. my all my problem is that reeturning value from /motor.php
0

add an onclick='return false;' to the form

2 Comments

it should post bc of your jquery function. but the return false stops the redirection of the page
now im done with the redirect as long as my action is action="javascript:;" if i change it, it still redirects. Anyway, even if i wrote $('#sonfiyat').html('asdasd'); $('#sonfiyat').show("fast"); it still do not rewrite that div
0

I think you need to post your motor.php code here as well.
Are you just using echo or print in your PHP code to return some HTML code?
How are you handling the variables that are being passed in?

You are passing some strange variables into the PHP document. {veri:$("#livehesap>input"),gorev:'son_fiyat_hesapla'}
I think you are looking for something like $("#livehesap").serialize()
http://api.jquery.com/serialize/

If you give us more information I am sure we can fix your problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.