Hi, can i ask some help to all experts, I have a form and i want to submit the form via jQuery ajax and i want to open this “to_my_other_page.php” it will open a new window,is this possible?
Please be aware though, that some people don’t have a PDF viewer installed/activated in their browser, so you might cause the file to get downloaded instead of viewed.
It was just an example of what you might return to your script, so that you are redirected on success.
Let’s put it another way: why do need to use AJAX for this.
Why can’t you set a normal link to (for example) generate-pdf.php and have this script generate a PDF and display the result?
Okay, i changed it to this way,and my problem is i could not get the text of the option example the “Manager”.
how can i get the text by using the submit() ?
Yeah, that’s what I mean, but I’m struggling to imagine why you would want to do this.
Can you describe what you are trying to do?
Maybe there’s a better way.
Okay i will describe i have a form and then inside my form i have <select> textbox and etc…now what i want to do is how am i going to submit the form to get the text of select via post and it will open to the new tab.
the value and text of the select option is requested via ajax,now if i am going to select the Lawyer i want the Lawyer to be post and submitted,…How can i achieve this ?
Well, usually a user will select which ever option is appropriate and submit the form themselves.
If you have a form which a user shouldn’t interact with, then maybe a form is the wrong way to go in this case.
You don’t have to use jQuery’s ajax() function with a form.
You can also use it in conjunction with a click event and submit the data to your PHP script that way.
Could you explain why you need to use a form here.
What is it that you are actually trying to do?
It might be a silly question, but is there a reason why you don’t just set the option element’s value attribute to “Teacher”, “Policeman”, “Lawyer” etc?
Do you need the values “0001”, “0002”, “0003” etc. in your PHP script, too?
yes, that’s what i plan to put the teacher in the value,but i think i am going also need the value in my php script later…is there other way ?..if not so, i will just use what you suggested to put the teacher in the value.
In this context .on() is synonymous with .click(), as we haven’t specified a selector.
So, it doesn’t matter which one you use.
However, if you have a dynamically generated element (for example coming from an AJAX call), you can use on to “delegate” the click event using a selector argument.
This replaces .live() in the latest jQuery.