Using Javascript to POST xml to api

后端 未结 2 1512

I\'m trying to post XML data and then do a redirect to the current page, but I can\'t seem to get it to work.

When I do this:

2条回答
  •  深忆病人
    2021-01-21 19:32

    This is an example on how to post with jQuery:

    var data = 
        '' +
        'This is a test' +
        'sample@example.com' + 
        ''
    $.support.cors = true;
    $.ajax({
        url: 'http://onehouse.freshdesk.com/helpdesk/tickets.xml',
        type: 'POST',
        crossDomain: true,
        data: data,
        dataType: 'text',
        username: 'username1',
        password: 'password1',
        success: function (result) {
            alert(result);
        },
        error: function (jqXHR, tranStatus, errorThrown) {
            alert(
                'Status: ' + jqXHR.status + ' ' + jqXHR.statusText + '. ' +
                'Response: ' + jqXHR.responseText
            );
        }
    });
    

提交回复
热议问题