Search code examples
ioscordovacross-domainphonegap-buildphonegap-cli

cross domain not working for ios phonegap


Actually I have a ajax request on phonegap for IOS platform. and I have two domain like 1. example.com/folder/contact.php?id=id and another one is 2. example2.com/folder/contact.php?id=id

So when url hit second domain (example2.com), it's nothing happening but for first domain(example.com) it's working properly. And I configured config.xml, here access-origin is "*" and also I have set in config.xml

I can't understand what is wrong. my ajax code is

$.ajax({
      type: 'GET',
      url: ""+localStorage.url+"/folder/contact.php?id=" + Id,
	  dataType: 'json',
	  crossDomain: true, 
	 
      data: {
        name: name,
        ph: ph,
        email:email,
        },
     success: function(response) {
		  alert(response);
},

error: function(error) {
		
        navigator.notification.alert('Could not connect to the database');
      }
    });

but same thing is working for android platform. Please suggest me what's wrong in my code


Solution

  • I have solved the problem. actually the problem was in page header meta content. I have to mention both domain example.com and example2.com in content gap. like this

    gap: https://ssl.gstatic.com https://*.googleapis.com http://example.com http://example2.com ;script-src 'self' 'unsafe-inline' 'unsafe-eval' https://maps.googleapis.com https://maps.gstatic.com https://mts1.googleapis.com https://mts0.googleapis.com http://example.com http://example2.com ;object-src * ; style-src 'self' 'unsafe-inline' https://ssl.gstatic.com https://fonts.googleapis.com http://example.com http://example2.com ; media-src *;img-src *;font-src *">