jquery

I am using pyramid to serve my app and have started learning jquery.I am trying to make a social widget for my app.

Domain 1(localhost: 8088 ) is making a request to anotherhost Domain2(10.20.12.135:8080/ which is actually localhost:8080) ie both are running on same system

Here is the code: Domain1

try{
    $.getJSON( "http://10.20.12.135:8080/ajax?name=stackoverflow", function( data ) {
    alert(data)
    }); } 
catch(err) {  
  alert("Ops, there was an error!nn" + err); 
}

Domain2:Reference

@view_config(route_name='ajax',renderer='json')
def get_cookie(request):
    name=request.get('name','world')
    return {'name':name,'id':343434,'secret':'3434sfdgdfg'}

When Domain1 is run firebug shows that the get request has return nothing and is in red.And none of the alert is shown.

Debugging jquery shows 'JSON.parse: unexpected end of data Line 4 '

However making a get request from browser to 10.20.12.135:8080/ajax?name=stackoverflow returns {'name':'stackoverflow','id':343434,'secret':'3434sfdgdfg'}

Instead of $.getJSON I tried $.ajax but got the same result(ie nothing)

2.While making jsonp request from domain1 to domain2, will the browser send the domain2 cookie as headers.

链接地址: http://www.djcxy.com/p/71952.html

上一篇: 金字塔:找不到静态资产

下一篇: jQuery的