Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
I can't seem to generate content for dynamic content load

I am using wordpress and php along with ajax to create a random loading of customer reviews on our main page

function loadContent() {
  $.ajax({
    type: "GET",
    url: 'http://skillsetsonline.ssosv.com/contentLoader.php',
    data: {
      company: 1
    },
    success: function(data) {
      alert(data);
      var currReview = document.getElementById('reviewRand');
      currReview.innerHTML = data;
    }
  });
}
setTimeout(loadContent, 10000); // milliseconds, so 10 seconds = 10000ms
<div id="reviewRand" class="elementToFadeInAndOut" style="font-color:#FFF;">Hi how are you</div>

I pasted the ajax command in from a stackoverflow posting that was an accepted answer but may not have it exactly right this does not include the fading CSS code I use but that is working I just need to change the content. Currently "Hi how are you" fades in every 10 seconds. One thing I have not learned about yet with this ajax command is the

data:{company:1}

I know it simply passes &company=1 to the GET URL but in my case I do not need to send anything and since it should not break anything if it is sent I left it alone not sure if

data:{}

would work and be cleaner I have verified that the url used does get a random review formatted like this

I love this program.blah blah.<br>
A USER<br>
A location<br>
June 2016<br>

Each line is formatted in CSS via a class tag

Any ideas would be greatly appreciated

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since the domain you're making the AJAX request to is on a different domain/origin, what you're running in to is a CORS issue. By default, the client will not allow you to update the page with data from an AJAX request that is served on a different origin than the site where the request originated. You can read about making CORS changes here https://enable-cors.org/

A common way around this is to serve the response via JSONP. You can do this in your script at http://skillsetsonline.ssosv.com/contentLoader.php if you have access to change that file. There are also third-party sites that will request that URL for you and create a proxy that serves the response via JSONP, then you can use it on your website.

Here's an example utilizing a JSONP proxy on https://crossorigin.me

function loadContent() {
  $.ajax({
    type: "GET",
    url: 'https://crossorigin.me/http://skillsetsonline.ssosv.com/contentLoader.php',
    success: function(data) {
      var currReview = document.getElementById('reviewRand');
      currReview.classList.add('ready');
      currReview.innerHTML = data;
    }
  });
}

setTimeout(loadContent, 0); /* changed this for the demo */
#reviewRand:not(.ready) {
    text-align: center;
}   
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="reviewRand"><img src="http://thinkfuture.com/wp-content/uploads/2013/10/loading_spinner.gif"></div>

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!