0

I'm using .get() to get html that include scheme relative. (like <a href="//example.com/pic.gif"> ) phonegap don't recognize the // and need http/s. Any tip for auto fix for that?

  $.getJSON('http://www.example.com/jsonAPI.php?action=post&postid='+id, function(data) {
    //alert("success"); 
    $('#setTitle').html(data.post.title);
  })  
  .fail(function() { alert("error"); })
  //.done(function() { alert("complete"); });
NoobSaibot
  • 204
  • 1
  • 2
  • 10
boaz
  • 25
  • 6

1 Answers1

0

The double forward slash // is shorthand for whatever url scheme the browser/webview is currently using. In PhoneGap, this is generally file:// -- so this won't work in PhoneGap.

One option might be to replace // with https:// in the response, something like this:

$.getJSON('http://www.example.com/jsonAPI.php?action=post&postid='+id, function(data) { 
  var title = data.post.title.replace(/href=[\"\']\/\//, "https://");
  $('#setTitle').html(data.post.title);
})  
.fail(function() { alert("error"); })
wildabeast
  • 1,723
  • 3
  • 18
  • 31