0

I've dug through dozens of related questions, and tried to implement but just can't quite get it to come together. I'm certain it is just some painfully simple miss, since I'm a rookie.

Redacted URL as it has sensitive data, but it prints to the console with the full array, so the ajax call seems to work. Just can't quite wrap my mind around the final step of display the results in a DIV. From reading, it seems like a Loop is necessary but can't quite get there.

<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

<div id="jsonpResult"></div>

<script>
$(document).ready(function(){
        $.ajax({
            url: '**MyURL**',
            data: {check: 'one'},
            dataType: 'jsonp',
            jsonp: 'callback',
            jsonpCallback: 'jobs',
            success: function(result){
                console.log(result);
            }
        });
    });

  function jsonpCallback(data){
       for(var i = 0 ; i < data.length ; i++){
            $('#jsonpResult').append(item.title+"<br />");
       }
   }
</script>
2

1 Answer 1

0

You might consider the following.

$(function() {
  $.ajax({
    url: '**MyURL**',
    data: {
      check: 'one'
    },
    dataType: 'jsonp',
    success: function(result) {
      console.log(result);
      $.each(result, function(i, item) {
        $("<div>").html(item.title).appendTo('#jsonpResult');
      });
    }
  });
});
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

<div id="jsonpResult"></div>

Without a Test URL, I am unable to test this code completely.

References:

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. Between this and the references you provided I was able to get it up and running. Very appreciative of your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.