0

I have a PHP file where we put ajax call refers below code, searchbtn is the button id which is places on php page.

$('#searchbtn').click(function(){
        $.ajax({
            type: "Post",
            url: "http://10.000.000.000:8080/testData/",
            success: function (result) { 
                console.log('dfdf');
            }
        })
    }); 

here we give a sample ip of java page.
here 'testData' is a controller of java page when we hit this URL below error comes.

XMLHttpRequest cannot load http://10.000.000.000:8080/testData/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

How to resolve this problem? Can we directly access java page? Is java page call simply or we use some other connection?

Arulkumar
  • 12,966
  • 14
  • 47
  • 68
Preeti Bisht
  • 69
  • 1
  • 1
  • 9
  • Nothing to do with Java or PHP. Your target API needs to support CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS – David Jan 14 '16 at 12:07
  • 1
    Related: https://stackoverflow.com/questions/5584923/a-cors-post-request-works-from-plain-javascript-but-why-not-with-jquery – Ferrybig Jan 14 '16 at 12:09

0 Answers0