Here is my code:
<body onload="ccform.submit();">
<form id="ccform" name="ccform" method="post" action="https://www.XXXX.com" runat="server">
<input type="hidden" name="id" value="XXX" />
.....
</form>
this works fine both on ie9 and chrome, but in the firefox, it stopped at the this page instead of posting to "https://www.XXXX.com".
then i changed the code to
<body>
<form id="ccform" name="ccform" method="post" action="https://www.XXXX.com" runat="server">
<input type="hidden" name="id" value="XXX" />
.....
</form>
<script type="text/javascript">
document.body.onload = ccform.submit();
</script>
it still worked on ie9 and chrome but not firefox. Does anyone know why? thanks
I agree with bfavaretto that it is strange to submit on page load.
If you want to submit when the document is ready, you can use jquery :
load jquery :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
and then post your form
<script>
$(document).ready(function(){
var form = jQuery("#ccform");
form.submit();
}
</script>
Related
I recently started a project that was going to download some data from a certain site. Unfortunately, when I wanted to download html with r.text, I got this code instead of the code I expected:
<html>
<head>
<title>Working...</title>
</head>
<body>
<form method="POST" name="hiddenform" action="some link"><input type="hidden" name="wa" value="wsignin1.0" /><input type="hidden" name="wresult" value="some links tokens and certificates" /><input type="hidden" name="wctx" value="some link" /><noscript><p>Script is disabled. Click Submit to continue.</p><input type="submit" value="Submit" /></noscript></form>
<script language="javascript">
window.setTimeout('document.forms[0].submit()', 0);
</script>
</body>
</html>
When I open this html code in webbrowser it redirects me to a certain site.
Can I send request with python requests module that will work just like that ?
If I did not explain something enough, I would be grateful to write it in a comment.
I would like to send data to a web page through javascript. The code below works, however only with chrome. For example Firefox the code does not work. Do you know another method to send data when loading page that works on all browsers?
<html>
<head>
</head>
<body>
<form name="FormType" method="post" action="/welcome.php">
<input type="hidden" name="var1" value="abc">
</form>
<script type="text/javascript">
function autoClick () {
document.forms["FormType"].submit();
}
window.onload = autoClick;
</script>
</body>
</html>
I'm trying to test the Cloudinary Uploader (via jquery and PHP).
I follow the instructions there:
http://cloudinary.com/documentation/php_image_upload#direct_uploading_from_the_browser
I'm interested to make it work as browser uploading (not server side).
My final HTML/script text is the following (I put some XXXX).
<html>
<head>
<title></title>
<script src="js/jquery-3.1.1.min.js"></script>
<script src='js/jquery.ui.widget.js' type='text/javascript'></script>
<script src='js/jquery.iframe-transport.js' type='text/javascript'></script>
<script src='js/jquery.fileupload.js' type='text/javascript'></script>
<script src='js/jquery.cloudinary.js' type='text/javascript'></script>
</head>
<body>
<script type='text/javascript'>
$.cloudinary.config({"api_key":"XXXXX","cloud_name":"XXXXX"});
</script>
<form action="uploaded.php" method="post">
<input class='cloudinary-fileupload' data-cloudinary-field='image_id' data-form-data='{"timestamp":1477780986,"callback":"http:\/\/www.XXXXX.XXX\/cloudinary\/cloudinary_cors.html","signature":"96872da4909f6acf00537c78ca41414ea73bXXXXX","api_key":"538456726987XXX"}' data-url='https://api.cloudinary.com/v1_1/di2a8qkzv/auto/upload' name='file' type='file'/> <input type="hidden" name="image_id" id="image_id" />
</form>
</body>
</html>
I just click the "Browse..." button and select a file, but nothing happens.
I have also the Firefox Console ON, but also I don't see any action.
As I understand, the form should automatically submit after the selection of the file. Right?
If not, what exact should I do to submit the file to Cloudinary?
What escapes me?
You have to initialize the input field as well. Try adding your code the following:
$('.cloudinary-fileupload').cloudinary_fileupload();
Make sure that this line is loaded last, so either put it at the end of the HTML or put it in a $( document ).ready() block.
On file input append this:
onchange="this.form.submit();"
Change this line of code:
<form action="uploaded.php" method="post">
<input class='cloudinary-fileupload' data-cloudinary-field='image_id' data-form-data='{"timestamp":1477780986,"callback":"http:\/\/www.XXXXX.XXX\/cloudinary\/cloudinary_cors.html","signature":"96872da4909f6acf00537c78ca41414ea73bXXXXX","api_key":"538456726987XXX"}' data-url='https://api.cloudinary.com/v1_1/di2a8qkzv/auto/upload' name='file' type='file'/> <input type="hidden" name="image_id" id="image_id" />
</form>
to:
<form action="uploaded.php" method="post">
<input onchange="this.form.submit();" class='cloudinary-fileupload' data-cloudinary-field='image_id' data-form-data='{"timestamp":1477780986,"callback":"http:\/\/www.XXXXX.XXX\/cloudinary\/cloudinary_cors.html","signature":"96872da4909f6acf00537c78ca41414ea73bXXXXX","api_key":"538456726987XXX"}' data-url='https://api.cloudinary.com/v1_1/di2a8qkzv/auto/upload' name='file' type='file'/> <input type="hidden" name="image_id" id="image_id" />
</form>
I am using jQuery form plugin to submit my form. It has a file element and when I am submitting it I am getting "too much recursion" in Firefox. It looks fine in IE 8. It works fine if I submit the form without selecting any file. Any idea?
I am calling ajaxForm() method this way.
jQuery("#myForm").ajaxForm();
Code Looks like below:
HTML Form:
<form action="someaction.do" method="post" enctype="multipart/form-data" id="myForm">
To : <input type="text" value="" name="subject"/>
Attachment : <input type="file" value="" name="attachement"/>
<input type="submit" value="Send"/>
</form>
Loading the following scripts
<script language="javascript" type="text/javascript" src="../js/jquery/jquery-1.6.js"> </script>
<script language="javascript" type="text/javascript" src="../js/jquery/jquery.form.js"></script>
While form is submitting ,
jQuery("#myForm").ajaxForm()
I have this code
<html>
<head>
<script type="text/javascript" src="my-search.js"></script>
</head>
<body onLoad="my_Init();">
<div>
<form name="id_msearchform" onsubmit="my_EventHandler_Action(); return false;">
<input type="text" name="id_searchphrase" value="example"></input>
<br><br>
<input type="submit" name="id_searchsubmit" value="Search"></input>
</form>
<br><br>
<div id="id_searchresults">No search done...</div>
</div>
</body>
</html>
I don't want the browser to request a new URL. That is why "onsubmit" has "return false;". This code works in Internet Explorer, but Firefox generates a new request. Any ideas what I am doing wrong?
FireBug changes between not wanting to acknowledge there is Javascript reference and showing the Javascript file without any errors... I will update this when i have more to add. I will try various thingsm e.g. try upload it to the net and see if FireFox behaves differently when not running JS on local disk.
Are you sure that you haven't got any errors?
I try with a simple html:
<html>
<head>
<script type="text/javascript" src="my-search.js"></script>
</head>
<body onLoad="my_Init();">
<div>
<form name="id_msearchform" onsubmit="my_EventHandler_Action(); return false;">
<input type="text" name="id_searchphrase" value="example"></input>
<br><br>
<input type="submit" name="id_searchsubmit" value="Search"></input>
</form>
<br><br>
<div id="id_searchresults">No search done...</div>
</div>
</body>
</html>
And a simple javascript called my-search.js in the same path of my html with the next code:
var my_Init = function(){
alert('Hello Onload');
}
var my_EventHandler_Action = function(){
alert('Hello OnSubmit');
}
And it works fine.
Can you show a live demo (with dropbox or something)?
Instead of using a submit button, try using a button and link the javascript function to that.