mardi 16 février 2016

Can i submit a HTML Salesforce form using Ajax with Visual Composer (Raw HTML and Raw JS)

Actually my question is that i am using Salesforce form in my wordpress website and using Visual Composer , when i use Raw HTML and put the Salesforce html form on Raw HTML element.When i submit form it redirecting on this "http://ift.tt/1bqiMqZ" after submission.
Now i want no redirection , i want when user submit form it should stay on same page or get a success message.for This purpose i am using this code which is below


<html><head>


<script type='text/javascript' >
function SubmitFormSF(){

var formData = jQuery('#sfcwForm').serialize();  
  jQuery.ajax({
    type: "POST",
    url: "http://ift.tt/1bqiMqZ",
    data: formData,
    success: function() {

    },
    error:function(error,data){
    JSON.stringify(error);
    JSON.stringify(data);
    console.log(error);
    console.log(data);
    $('#sucess').html('This is Done');

    }
  });
jQuery('#email').val("");
jQuery('#first_name').val("");
jQuery('#phone').val("");

}

</script>
</head>
<body>
<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: Please add the following <META> element to your page <HEAD>.      -->
<!--  If necessary, please modify the charset parameter to specify the        -->
<!--  character set of your HTML page.                                        -->
<!--  ----------------------------------------------------------------------  -->

<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: Please add the following <FORM> element to your page.             -->
<!--  ----------------------------------------------------------------------  -->

<form action="http://ift.tt/1bqiMqZ" method="POST" class="Salesforce_form" id="sfcwForm">

<input type=hidden name="oid" value="xxxxxxxxxxxxxx">
<input type=hidden name="retURL" value="">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: These fields are optional debugging elements. Please uncomment    -->
<!--  these lines if you wish to test in debug mode.                          -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail"                                  -->
<!--  value="xxxxx.xxxxx@xxxxxxxxxx.com">                                  -->
<!--  ----------------------------------------------------------------------  -->

<input  id="first_name" maxlength="40" name="first_name" size="20" type="text" class="form_filed"  placeholder="your name" id="sf_field" required/><br>
<input  id="email" maxlength="80" name="email" size="20" type="text"  class="form_filed" placeholder="your email address" id="sf_field" required/><br>
<input  id="phone" maxlength="40" name="phone" size="20" type="text"  class="form_filed" placeholder ="phone number" id="sf_field"required/><br>
<label for="Palce of Residene"><strong>Palce of Residene?</strong></label></br>
<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi"  type="radio" value="NSW" />NSW &nbsp<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi"  type="radio" value="QLD" />QLD &nbsp<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi"  type="radio" value="VIC" />VIC &nbsp<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi"  type="radio" value="WA" />WA&nbsp<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi"  type="radio" value="TAS" />TAS&nbsp<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi" size="20" type="radio" value="SA" />SA&nbsp<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi" size="20" type="radio" value="NT" />NT&nbsp<input  id="00N28000009KSdi" maxlength="255" name="00N28000009KSdi" size="20" type="radio" value="International" />International</br></br>
<label for="Im interested"><strong>Im interested</strong></label></br>
<input  id="00N28000009KSeW" maxlength="255" name="00N28000009KSeW"  type="radio" value="Super" />Super&nbsp<input  id="00N28000009KSeW" maxlength="255" name="00N28000009KSeW"  type="radio" value="Manage Funds" />Manage Funds&nbsp<input  id="00N28000009KSeW" maxlength="255" name="00N28000009KSeW"  type="radio" value="Both" />Both</br>
<input  id="00N28000009KSeW" maxlength="255" name="00N28000009KSeW"  type="checkbox" value="Investment E-Newsletter (Quarterly)" />Investment E-Newsletter (Quarterly)&nbsp<input  id="00N28000009KSeW" maxlength="255" name="00N28000009KSeW"  type="checkbox" value="-Newsletter for Financial Planners" />-Newsletter for Financial Planners</br>

<input type="button" value="submit" class="sfSubmit" id="btnSF" onclick="SubmitFormSF();"/>
<div id="sucess"></div>
</form>
</body>
</html>

So i pasted JS code in Raw Js(VC Element) and HTML in Raw Html(VC Element).but it is not working. But it is working when i use it as Simple HTML File. So i am stuck on this point that why it is not running Visual Composer element. Now tell me where i am making mistake. Thanks adn looking forward your soonest response.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire