The response of my request is a java script code. When I put the url in browser, I can see the whole generated java script code on the page. Format of url passed to $.ajax is as below:
http://localhost:8080/vi-api/viapi?action=tag&projectId=45&tagId=345
When I put the above URL I can see the request is successful. Now, I am using below Ajax request for this url using jQuery.
var finalUrl = "http://localhost:8080/vi-api/viapi?action=tag&projectId=45&tagId=345"; var req = $.ajax({ type:"GET", url:finalUrl, type:"script", data:"", success: function(html){ alert('Requese sucessful.'); }, complete:function(jqXHR, textStatus) { alert("request complete "+textStatus); }, error: function(xhr, textStatus, errorThrown){ alert('request failed->'+textStatus); } });
Question 1:This gives the alert "request failed error'. Why this is so ?
Question 2:Is there any way to return success/failure code in above process?