AJAX call to PHP not working yields a blank page - ajax

We are implementing the "forget password" feature for our website.
We are usign HTML, JQquery mobile and AJAX .
we have a main file, which has the hyperlink for the forget password using the '' tag.
The password.html has form elements as below:
<form method ="post" id="forget" action="somefile.php" >
<h4>Enter your login email to change your password..</h4>
<label for="email" class="ui-hidden-accessible">Email:</label>
<input type="email" name="email" id="email" value="" placeholder="email" data-theme="a" />
<input type="submit" value="Submit" data-theme="b" />
</div>
</form>
The php file validates the email and sends the response in JSON format , which we are handling through a ajax call.
The problem is after hitting on "submit" in the password.html, we are able to retreive the data from the php file(able to see in network tab of browser) but it does not display on the frontend.
The browser is navigating to the php file (which it should not) and a blank page is being displayed.
Ps: When we directly load the password.html in the browser the behaviour is absoultely fine , but when we are navigating from the main file usign the hyperlink to password.html then this problem occurs.

Related

GSA Cookie Auth - "Login form doesn't have both text and password inputs"

I can't seem to find out what's wrong with the login form I'm using to setup cookie authentication, the GSA throws me this error (serving log) after submitting my credentials in universal login form:
Got form; name=customlogin clientLogin; action=/content/marketing/en/login/j_security_check; type=hidden, name=resource; type=hidden, name=_charset_; type=hidden, name=j_username; type=hidden, name=j_password
Login form doesn't have both text and password inputs
Error in authentication module: Login form doesn't have both text and password inputs
Here is the form I'm using:
<form method="POST" action="/content/marketing/en/login/j_security_check" id="form_customlogin" name="customlogin clientLogin" enctype="multipart/form-data" onsubmit="return cq5forms_validate_customlogin();">
<input type="hidden" name="resource" value="/content/operations/apps/en.html" />
<input type="hidden" name="_charset_" value="UTF-8" />
<input id="username" type="hidden" name="j_username" value="anonymous-user" />
<input id="password" type="hidden" name="j_password" value="anon" />
<p>
Or go straight through as a
guest
(limited access)
</p>
</form>
Does anyone have knowledge on how a form has to be built in order for the GSA to use it? It'd be very welcome.
Thanks in advance!
EDIT: Apparently, inputfilds user/pw must have type username and password, they can't be hidden.
This was already a feature request.
The username field will have to be type="text", there is no type="username". Out of curiosity, why would you have them hidden?
Very often, when you have complicated login forms, your best bet is to create a separate login form just for the GSA that doesn't include any JavaScript or other wackiness.

Search-form action attribute with Advanced AJAX Page Loader wordpress plugin returns "more than one title tag on the page.." warning in debug mode

I'm trying to enable search functionality of the Advanced AJAX Page Loader plugin on a custom wordpress theme I'm building, but after I enter keyword into search and hit enter, loader.gif keeps on spinning and I get this message in debug mode : "WARNING: You seem to have more than one title tag on the page, this is going to cause some major problems so page title changing is disabled". It also passes the url of the website twice into the address bar and I believe this has something to do with the action attribute that's being passed by the form.
This is the site in question: http://natalija.co.nf
I left the debug mode of the AAPL plugin on for now
This is my searchform.php code:
<form method="get" id="searchform" class="searchform" action="<?php bloginfo('url'); ?>">
<input type="submit" id="searchsubmit" value="" class="btn" />
<input type="text" size="10" name="s" id="s" value="" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>
</form>
I managed to ajaxify the theme with this plugin but I 'm having trouble getting the search to work properly so I was wondering if anyone here can help me out with this? It is driving me crazy.
I solved it. The code in search.php needs to be wrapped with a div class="searchform".

AJAX file upload with progress bar and input types

I need to submit form which contains two inputs:
<form action="upload" method="post" accept-charset="utf-8" enctype="multipart/form-data"
id="upload">
<textarea name="file_description"></textarea><br/>
<input type="file" name="userfile" id="userfile" /><br/>
<input type="submit" name="upload_button" value="upload"/>
</form>
This question maybe duplicate of this, but I tried and get errors. Can anyone guide me with submitting form which contains file and other inputs?
You can use XHR2 and FileAPI. It's new HTML5 API with pretty good browser support by now. XHR2 allows you to send files via AJAX and FileAPI is used to get file content from input[type=file]
There are plenty articles on that subject in the web. For example: Processing XHR2 file uploads in PHP

MVC 3 File Upload

I want to use mulitple File uploaders on my Razor view form. For this I tried File upload Web helper (#FileUpload.Gethtml()) but unable to call desired controller action. Any help on this or some other way will be highly appreciated.
Thanks
Vivek
You could use a simple html form with multiple file upload inputs and set the form action to post your controlle action
For example
<div>
<h2>File Uploads Updates</h2>
<form action="/FileUpload/UploadMultiple" method="post" enctype="multipart/form-data">
<label for="file">FileAt:</label>
<input type="file" name="fileA" id="fileA" /><br />
<label for="file">FileB:</label>
<input type="file" name="FileB" id="FileB" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
</div>
See Also this Hanselman post on how to do file uploads in MVC
If you're willing to use third party controls, take a look into Telerik upload control.
It is an open source one (GPL 2 ? license)

Chrome not sending POST requests on localhost, Firefox works fine

I have copied the simple Django forms example exactly, running on localhost. The basic contact form example should submit a POST request when you click the Submit button.
I'm running Chrome on Mac Snow Leopard, and whenever I submit the form, the page simply reloads with an empty form: I can see from the runserver output that it's not sending a POST - instead it's sending a GET request.
If I open the same page in Firefox on Mac Snow Leopard, and submit the form, I can see it's sending a POST request (as it should be).
Looking at the source in Chrome, the form definitely says method="post".
<form action="/contact/" method="post">
<p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" /></p>
<p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></p>
<p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" /></p>
<p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p>
<input type="submit" value="Submit" />
</form>
External sites with POST forms seem to work OK in Chrome.
In addition, if I fill the form in incorrectly, in Chrome the page just reloads, with a GET request, as before; in Firefox the form gets validated, as it should.
I've tried with other POST forms on localhost and got the same result.
I know Chrome for Mac has its quirks, but what on earth is going on?
This is likely being caused by Chrome treating each file:// URL as a different domain. Try launching Chrome with the --allow-file-access-from-files option and see if that helps.
Update: You'll have to close all existing Chrome instances and launch a fresh instance with that option to notice any difference.

Resources