Created
August 13, 2017 17:24
-
-
Save justyntemme/25071026480fafd98f7d5d8b29d4aa6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var invocation = new XMLHttpRequest(); | |
//First Product will be sent by defualt; the next will be checkedif not equal to ----- | |
jQuery.get("https://api.pipedrive.com/v1/products/find?term=" + jQuery("#field53412749").val() + "¤cy=USD&start=0&api_token=REDACTED", function(resp){ | |
console.log(jQuery("#field53412749").val()) | |
callOtherDomain(resp.data[1].id); | |
}); | |
var url = "https://api.pipedrive.com/v1/deals/" + pipedrive_deal_ID + "/products?api_token=REDACTED"; | |
function callOtherDomain(firstProductID){ | |
var firstProductData = `{ | |
"id": "` + pipedrive_deal_ID + `", | |
"product_id": "` + firstProductID +`", | |
"item_price": "` + jQuery("#field53456315").val() + `", | |
"quantity": "` + jQuery("#field53412750").val() + `", | |
"discount_percentage": "` + (parseInt(jQuery("#field53455830").val().replace("%", "") * 100)) + `", | |
"duration": "1" | |
}` | |
if(invocation) | |
{ | |
invocation.open('POST', url, true); | |
invocation.setRequestHeader('X-PINGOTHER', 'pingpong'); | |
invocation.setRequestHeader('Content-Type', 'application/json'); | |
//invocation.onreadystatechange = handler; | |
invocation.send(firstProductData) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment