[jQuery]Trouble getting Ajax to connect to my hosted RESTful service. via /r/learnprogramming


[jQuery]Trouble getting Ajax to connect to my hosted RESTful service.

$.ajax({ type: "GET", url: "http://ift.tt/2tWWa0W;, dataType:"json", success: function (result) { write('success!!'); }, error: function (jqXHR, textStatus,errorThrown) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect.\n Verify Network.'; write(textStatus); write(errorThrown); } else if (jqXHR.status === 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status === 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error.\n' + jqXHR.responseText; } write(msg); } }) 

This is my current ajax call. Here you can find my restful service.

I am only getting jqxhr.status === 0 when I try to do the ajax call(not connected, verify network), with textStatus returning "error". I was having this issue when my service was hosted locally, so I've tried both "json", and "jsonp" as a dataType.

I've tried using a public restful service such as this one, and I am able to get a successful connection.

Any help would be appreciated! Thanks!

Submitted July 16, 2017 at 03:02AM by agent_neeyawn
via reddit http://ift.tt/2tsU9WG

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s