2016-06-10 256 views
2

我需要轉換下面捲曲請求,AJAX,轉換捲曲AJAX請求

CURL : $ curl -X POST http://textbelt.com/text -d number=5551234567 -d "message=I sent this message for free with textbelt.com" 

我寫的AJAX請求低於:

$.ajax({ 
    type: 'post', 
    url: "http://textbelt.com/text",   
    data: "number=+1********** message='This is a test message!",   

    success:function(response) 
    { 
     console.log("Success!!"); 
    }, 

    error : function(xhr, status, error) 
    { 
     console.log("Status of error message" + status + "Error is" + error); 
    } 

}); 

我從一開始的反應服務器是:

{ 
     "success": false, 
     "message": "Number and message parameters are required." 
    } 

任何人都可以請指導我在正確的方向嗎?

回答

1
$.ajax({ 
type: 'post', 
url: "http://textbelt.com/text",   
data: {"number":"+1**********", "message":"This is a test message!"},   

success:function(response) 
{ 
    console.log("Success!!"); 
}, 

error : function(xhr, status, error) 
{ 
    console.log("Status of error message" + status + "Error is" + error); 
} 

}); 

以上應該工作。

+0

感謝您的回答!有用 :) –