Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var QueryString = function () {
- var query_string = {};
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if (typeof query_string[pair[0]] === "undefined") {
- query_string[pair[0]] = decodeURIComponent(pair[1]);
- } else if (typeof query_string[pair[0]] === "string") {
- var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
- query_string[pair[0]] = arr;
- } else {
- query_string[pair[0]].push(decodeURIComponent(pair[1]));
- }
- }
- return query_string;
- }();
- /* user parameters */
- var webmaster_id = WEBMASTER_ID;
- var webmaster_api = 'WEBMASTER_API';
- var product_id = PRODUCT_ID;
- /* not change */
- var client_ip = '127.0.0.1';
- var client_s = '';
- var client_w = '';
- var client_t = '';
- var client_p = '';
- var client_m = '';
- function sendData(client_name, client_phone) {
- $.ajax({
- type: 'POST',
- data: {
- ref: WEBMASTER_ID,
- api_key: WEBMASTER_API,
- product_id: PRODUCT_ID,
- phone: client_phone,
- name: client_name,
- ip: client_ip,
- s: client_s,
- w: client_w,
- t: client_t,
- p: client_p,
- m: client_m,
- referer: document.referrer,
- },
- url: 'https://m1-shop.ru/send_order/',
- success: function(data) {
- //console.log(data);
- data = JSON.parse(data);
- if (data.result == "ok") {
- //alert('Заказ создан, ID:' + data.id);
- window.location.replace("call.php?order_id=" + data.id + "&s=" + client_s + "&w=" + client_w + "&t=" + client_t + "&p=" + client_p + "&m=" + client_m);
- }
- else {
- //alert('Заказ НЕ создан, ответ: ' + data);
- window.location.replace("call.php?s=" + client_s + "&w=" + client_w + "&t=" + client_t + "&p=" + client_p + "&m=" + client_m);
- }
- },
- error: function(xhr, status, error) { // if error occured
- console.log(xhr.statusText, xhr.responseText, status, error);
- respjs = JSON.parse(xhr.responseText);
- //alert('Заказ НЕ создан, ответ: ' + respjs.message);
- window.location.replace("call.php?s=" + client_s + "&w=" + client_w + "&t=" + client_t + "&p=" + client_p + "&m=" + client_m); //$(placeholder).append(xhr.statusText + xhr.responseText);
- //$(placeholder).removeClass('loading');
- }
- });
- return false;
- };
- $(document).ready(function() {
- client_s = QueryString.s;
- client_w = QueryString.w;
- client_t = QueryString.t;
- client_p = QueryString.p;
- client_m = QueryString.m;
- $.getJSON('https://ipapi.co/json/', function(data) {
- //console.log(JSON.stringify(data, null, 2));
- json_data = data;
- client_ip = json_data.ip;
- //console.log(client_ip);
- });
- $('form').submit(function() {
- $('input[name=name]', this).val($.trim($('input[name=name]', this).val()));
- if (!$('input[name=name]', this).val()) {
- alert('Укажите корректные ФИО!');
- return false;
- }
- if (!$('input[name=phone]', this).val() || $('input[name=phone]', this).val().length < 7) {
- alert('Укажите корректный телефон!');
- return false;
- }
- sendData($('input[name=name]', this).val(), $('input[name=phone]', this).val());
- return false;
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement