I have a ajax code as follows
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status==200) {
token=xhr.responseText;
//add value/field to form
txCvv = txJ$(".cvv").val();
var MyForm = txJ$(".submit").closest("form");
if (txJ$('#cipherText').length > 0) {
txJ$('#cipherText').val(txCryptData);
}
else
{
txJ$('<input type="hidden">').attr({
id: 'token',
name: 'token'
}).val(token).appendTo(MyForm);
txJ$('<input type="hidden">').attr({
id: 'cvv',
name: 'cvv'
}).val(txCvv).appendTo(MyForm);
}
//scrub data that we do not want to post
txJ$(".data").removeAttr('name');
txJ$(".cvv").removeAttr('name');
}
}
xhr.open('POST', 'tokenize.php', true);
xhr.send(params);
The tokenize.php resides in my server and the ajax is working fine.This javascript also resides on my server.When from a different server,I added the javascript source on my server,but it showed me error,that it tried to access tokenize.php from that server.
The tokenize.php is
<?php
$encrypted_data = file_get_contents("php://input");
//There are some codes here.
echo $output;
<?
I can use the javascript in my server and get a data from php to the script easily.But if I want to use the javascript for my clients,or any one who is on a different server,how would they get the data from php file on my server?
I have seen online about jsonP ,in which request can be made from remote server.In my codes,is it possible to implement jsonP ,so that my clients can access datas from tokenize.php which is on my server,if yes,what modification should I do.Im really new to jquery,so finding it hard to figure it out,please help