You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

JavaScript API - using AJAX

Accepted answer
19
Views
12
Comments
edited Nov 9, 2016 3:14PM in UI Extensibility 12 comments

Content

I have the following script, and another script on the cloud that return a value(php - webservice)  ( it was tested with other programming languages and it worked), i even executed the $.ajax block in a HTML file outside the cloud, and it worked, i am trying to execute the script when the user tries to save a new contact, but the $.ajax block is not working, i can only see the alert "test" when i click on the save button,what am i doing wrong here?

 

Version

May 2016

Code Snippet

             <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
	var contactExistInfo = [];
	
	function onbeforesave()
	{
		
		var contact = window.external.Contact;
		var contactId = contact.Id;

		var errorMessage = "";

		alert("test");
		$.ajax({
      		url: 'https://azadearnw--tst1.custhelp.com/cgi-bin/azadearnw.cfg/php/custom/checkcontactphone.php',
      		type: 'post',
      		data: {'phone': '3573077', 'code': '00961'},
      		success: function(data) {
        		alert(data);
     		 },

      		error: function(xhr, desc, err) {
        		console.log(xhr);
       

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!