I have a few buttons in my script that call window.open(‘myUploadScript.php?arguments=test…’,”).
I’m passing querystring parameters in the arguments() for the target file myUploadScript.php to process.
I’d like to call this script without opening it in a popup. Can I use jQuery for this without having to start from scratch on my popup window script?
In other words, my window.open contains:
<input
type="button"
id="myButton"
value="myValue"
onclick="window.open('myUploadScript.php?action=test',
'popup',
'width=330,
height=300,
scrollbars=no,
resizable=no,
toolbar=no,
directories=no,
location=no,
menubar=no,
status=no');
return false"
/>
Can I instead call a jQuery that loads the contents of myUploadScript.php into a placeholder div, passing it the “test” argument?
You can easily do it as other posters explained. However, if it’s an actual file upload script, this will not help you.
The issue is that file upload doesn’t work via AJAX (only works in select browsers, but not generally). The only way to implement ajax file upload in pure html/javascript is using iframe, like so:
What this does is post the upload into a hidden iframe. The iframe has to emit javascript which will tell the page that it’s done, something like this: