0

I'm used this code to pass parameter from jQuery to ASHX, actually I want to upload file using Uploadify Plugin and send Parameter named 'Id' to ASHX

function CallHandler() {
    $.ajax({
        url: "PIU.ashx/MyMethod",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: { 'Id': '10000' },
        responseType: "json",
        success: OnComplete,
        error: OnFail
    });
    return false;
}

function OnComplete(result) {
    alert(result);
}
function OnFail(result) {
    alert('Request Failed');
}

and this ASHX code:

public void ProcessRequest(HttpContext context)
{
    var employee = Convert.ToInt32(context.Request["Id"]);

    JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
    string serEmployee = javaScriptSerializer.Serialize(employee);
    context.Response.ContentType = "text/html/plain";
    context.Response.Write(serEmployee);

    parent MyParent = (parent)context.Session["mahdZNUparent"];

    //the file data is the file that posted by Uploadify plugin
    HttpPostedFile PostedFile = context.Request.Files["Filedata"];

    string FileName = PostedFile.FileName; // whene i comment this line, the code works
    // properly, but when uncomment this line, the code get to 'Request Failed'
}

public bool IsReusable
{
    get
    {
        return false;
    }
}

how can I Solve this problem!!!!!!!

1 Answer 1

1

You may want to take a loot at this: http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/

And this one too: Using jQuery for AJAX with ASP.NET Webforms

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.