function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Varun ChopraVarun Chopra 

Ajax call on visualforce page

Hi I am triying to run ajax on my visualforce page. But I am getting ready state= 0.
In chrome I was getting following error.

No 'Access-Control-Allow-Origin' header is present on the requested resource.


Here is my code
$.ajax({
            type:"GET",
            url:'https://www.foragentsonly.com/',
            dataType:"html",
            beforeSend: function(xhr) {
               xhr.setRequestHeader('X-User-Agent', 'MyClient');
            },
            success:function(data) {
                alert(data);
              
            },
            error:function(errorStatus,xhr) {
                alert("Error"+JSON.stringify(errorStatus));
            }
        });
  // document.getElementById('theIframe').src = url;

}

Raja ReddyRaja Reddy
I had a same issues earlier and resolved by adding " Allow-Control-Allow-Origin" plugin to chrome browser.

Try it.