PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 13, 2022

[FIXED] How to set a parameter at the end of my URL

 March 13, 2022     forms, javascript, wordpress     No comments   

Issue

I have a form at Contact Forms 7 to get my clients to receive a call in 30 minutes. A guy built us a API that does the job. But I need to add the phone number automatically to the end of the external URL (not my contact page nor the thank you page). When submitted, the form redirects to a 'thank you page' and should fire a javascript that sets the phone number at the end of the URL.

Im new to Javascript but I've tried this code by prieston, but i don't really know what I'm doing. Can anyone help?

I've also tried the CF7 to Webhook but it didnt work.


Solution

We managed to make it work with Javascript/AJAX with the following code.

    var url = "https://www.urloftheAPI.com";

var xhr = new XMLHttpRequest();
xhr.open("POST", url);

xhr.setRequestHeader("Content-Type", "application/json");

var data = `{  
    "phone": "[phone]",
    "id": "company's id in the system of the api"
}`;

xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
      console.log(xhr.status);
      console.log(xhr.responseText);
      console.log(data);
   }};

xhr.send(data);

The code was fired with the plug-in Redirection for Contact Form 7 by Qube One.

The redirection to a 'thank you page' was made with the same plugin.



Answered By - Sarah
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing