Link to home
Start Free TrialLog in
Avatar of dynamicweb09
dynamicweb09Flag for India

asked on

AJAX error in request

I am calling WCF REST using Jquery, that works fine in IE,But is not working in any other browser like Mozilla,Chrome . while calling the WCF REST from like Mozilla Firefox I am getting the error :

AJAX error in request: {
  "readyState": 0,
  "responseText": "",
  "status": 0,
  "statusText": "error"
}

Open in new window


I am attaching the code:
<script type="text/javascript">
    $(document).ready(function(){	
	
	// Declare all the variables.
	var exampleValues = {};
	var Activity = 'SELL';
	var Exchange = 'NSE';
	var param1 = 'ALL';
	var param2 = ' ';
	var param3 = 'ALL';
	var param4 = 'xxxx';
	var str = "http://santu-379/WCFClient/WCFClient.Service1.svc/GetFirst_PDH_PDL/" + Activity + "/" + Exchange + "/" + param1 + "/" + param2  + "/" + param3 + "/" + param4;
//alert(str);
	jQuery.support.cors = true;
	$.ajax({
		 url: str,
		 type: "GET",
		 async: "false",
		 data: '{}',
		 crossDomain: true,
		 contentType: "application/json; charset=utf-8",
		 dataType: "json",
		 
		 //processData: true,
		 complete: function() {
		   // alert('done');
		    },
		 success: function(data)
		  {
		     //alert(data);
		      var obj = $.parseJSON(data);		       
		      $('#templateStructure').template('myTemplate');
		      // bind the data to the template and append to the table
		      $.tmpl('myTemplate', obj).appendTo('#templateTable');
		      //$("#flickrTemplate").tmpl((obj)).appendTo("#placeholder");
		  },
		 error: function (err) {
		       alert("AJAX error in request: " + JSON.stringify(err, null, 2));
	       } 
	});
	
	
	});
	
    
    </script>

Open in new window

Avatar of jayakrishnabh
jayakrishnabh

Please try this...
Limit url string to till Methodname and pass the parameters through JSON data.
Example :
var str = "http://santu-379/WCFClient/WCFClient.Service1.svc/GetFirst_PDH_PDL/";
//(if GetFirst_PDH_PDL is the method name that has four input parameters Param1Name, //Param2Name, Param3Name, Param4Name)
var jsonData = { Param1Name : param1, Param2Name : param2, Param3Name : param3, Param4Name : param4}

$.ajax({
             url: str,
             type: "GET",
             async: "false",
             data: jsonData ,
             crossDomain: true,
             contentType: "application/json; charset=utf-8",
             dataType: "json",
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please post the WCF operation declaration of GetFirst_PDH_PDL.
Need to check how the URI is defined as well as the method parameters.
Avatar of dynamicweb09

ASKER

ok
why a "C" grade ?